【问题标题】:iphone: how make Multiple Columns in UITableView [duplicate]iphone:如何在 UITableView 中制作多列 [重复]
【发布时间】:2012-12-14 05:25:46
【问题描述】:

可能重复:
How to display multiple columns in a UITableView?

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

【问题讨论】:

标签: iphone ios uitableview multiple-columns


【解决方案1】:

使用 GridView 来满足您的这一要求,请参阅下面的演示和教程链接...

  1. Grid-View-in-IPhone-using-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;
}

希望对你有所帮助...

【讨论】:

  • @ani 使用我的回答中的第一个选项此链接mindfiresolutions.com/… 在这里您可以在 tableview 中设置多列
【解决方案2】:

你可以继承你的 tableViewCell 或者你可以使用这个MDSpreadView

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2017-01-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多