0
我有一個場景,我想保留tableview的行上的圖像的「縮略圖」。我在運行時決定連續排列的圖像數量。其次,點擊任何圖像我想啓動一個視圖控制器與詳細描述它的形象。UItableView具有多個圖像,並在其中每一個上設置onclick
我該如何做到這一點?
|________________|
| 1 2 3 4 5 6 |
|________________|
| 7 8 9 10 11 12 |
|________________|
| 12 14 15 |
|________________|
想象一下上面的數字作爲縮略圖。點擊任何數字我想啓動一個新的視圖控制器,提供有關圖像的詳細信息。
代碼片段:
-(void) populateTableView
{
NSMutableArray* srcArray = [[NSMutableArray alloc] initWithArray:[[ImageDataSource sharedImageDataSource] getThumbnailsSrcArray]];
int noOfImages = srcArray.count;
float rowc = (noOfImages/ROW_ELEM_COUNT) + 0.5;
int rowCount = roundf(rowc);
titleData = [[NSMutableArray alloc]init];
int j=0;
for (int i=0; i<rowCount; i++) {
NSMutableArray* rowArray = [[NSMutableArray alloc] init];
for (int k=0; k < ROW_ELEM_COUNT; k++) {
if (j < noOfImages) {
NSString* imgPath = [srcArray objectAtIndex:j];
UIImage* img = [[UIImage alloc] initWithContentsOfFile:imgPath];
[rowArray addObject:img];
[img release];
imgPath=nil;
}
j++;
}
[titleData addObject:rowArray];
}
titleView = [[UITableView alloc] initWithFrame:CGRectMake(90.0,156.0,590.0,630.0)
style:UITableViewStyleGrouped];
titleView.delegate = self;
[self.view addSubview:titleView];
[titleView release];
}
所以基本上我有數組作爲我的DS的陣列。每個數組的索引將是表格視圖的行,並且數組裏面將會有圖像。但我不知道如何填充tableview。 任何線索任何人?
我一定要繼承的UITableViewCell與否?如果我們在 - (UITableViewCell *)中創建它們應該沒問題。tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath –
是的,您可以輕鬆地將子視圖添加到單元格中。 contentView'在這個方法中。 – runmad