テーブルビューの行に画像の「サムネイル」を残したいというシナリオがあります。実行時に、連続する画像の数を決定します。
次に、画像のいずれかをクリックすると、説明付きの詳細な画像を含むビューコントローラを起動します。
どうすればこれを達成できますか?
|________________|
| 1 2 3 4 5 6 |
|________________|
| 7 8 9 10 11 12 |
|________________|
| 12 14 15 |
|________________|
上記の数字をサムネイルとして想像してみてください。画像の詳細を表示する新しいViewControllerを起動したい番号のいずれかをクリックします。
コードスニペット:
-(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として配列の配列があります。各配列のインデックスはテーブルビューの行になり、内部の配列には画像が含まれます。しかし、テーブルビューにデータを入力する方法がわかりません。誰か手がかりはありますか?