【发布时间】:2012-05-05 01:42:38
【问题描述】:
我有一个场景,我想在 tableview 的行上保留图像的“缩略图”。我在运行时决定连续的图像数量。
其次,单击任何图像时,我想启动一个视图控制器,其中包含详细的图像和一些描述。
我怎样才能做到这一点?
|________________|
| 1 2 3 4 5 6 |
|________________|
| 7 8 9 10 11 12 |
|________________|
| 12 14 15 |
|________________|
把上面的数字想象成缩略图。单击任何数字我想启动一个新的视图控制器,它会提供有关图像的详细信息。
代码sn-p:
-(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。每个数组的索引将是表格视图的行,并且里面的数组将有图像。但我不确定如何填充表格视图。 有人知道吗?
【问题讨论】:
标签: ios uitableview