重複の可能性:
UITableView に複数の列を表示する方法は?
複数の行と列のデータがあります。しかし、iPhone UITableView には単一の列と複数の行しか含まれていません。Apple のヒューマン インターフェイス ガイドラインに従って複数列のデータを表示するにはどうすればよいですか? 何か案は?
重複の可能性:
UITableView に複数の列を表示する方法は?
複数の行と列のデータがあります。しかし、iPhone UITableView には単一の列と複数の行しか含まれていません。Apple のヒューマン インターフェイス ガイドラインに従って複数列のデータを表示するにはどうすればよいですか? 何か案は?
この要件には GridView を使用します。デモとチュートリアルについては、次のリンクを参照してください ...
以下のコードを使用して、複数の列を持つタイムテーブルを表示します。例のコード..
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString* cellIdentifier = @"gridCell";
UITableViewCell *gridCell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier];
if(gridCell == nil)
{
gridCell = [[[UITableViewCellalloc] initWithStyle:UITableViewCellStyleDefaultreuseIdentifier:cellIdentifier] autorelease];
gridCell.accessoryType = UITableViewCellAccessoryNone;
gridCell.selectionStyle = UITableViewCellSelectionStyleNone;
}
NSArray* items = [_grids objectAtIndex:indexPath.section];
int imageIndex = 0;
int yOffset = 0;
while (imageIndex < items.count)
{
int yPos = 4 + yOffset * 74;
for(int i = 0; i < 4; ++i)
{
CGRect rect = CGRectMake((18 + i * 80), yPos, 40, 40);
UIImageView* imageView = [self gridImageRect:rect forImage:[items objectAtIndex:imageIndex]];
[gridCell.contentView addSubview:imageView];
[imageView release];
rect = CGRectMake(((80 * i)-4), (yPos+44), 80, 12);
UILabel* label = [self descriptionOfImage:imageIndex inRect:rect];
[gridCell.contentView addSubview:label];
[label release];
++imageIndex;
}
++yOffset;
}
return gridCell;
}
これがお役に立てば幸いです...