iphone:如何在UITableView中制作多列

可能重复:
如何在UITableView中显示多个列?

我有多行和多列数据。 但是iPhone UITableView只包含单列和多行。 如何按照Apple的人机界面指南显示我的多列数据? 有任何想法吗?

使用GridView满足您的要求,请参阅演示和教程的以下链接…

  1. 网格视图function于IPhone,使用-的UITableView-1665
  2. GMGridView
  3. UIGridView

我使用下面的代码来显示具有多列的时间表,一些代码用于示例..

- (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; } 

我希望这有助于你......

您可以将tableViewCell子类化,也可以使用此MDSpreadView