Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iphone: how make Multiple Columns in UITableView [duplicate]

Possible Duplicate:
How to display multiple columns in a UITableView?

I have multiple rows and columns of data. But iPhone UITableView contains only single column and multiple rows. How do I display my multi column data following Apple's Human Interface Guidelines? Any ideas?

like image 289
ani Avatar asked Dec 26 '22 13:12

ani


1 Answers

Use GridView for your this requirement, see this bellow links for the Demos and Tutorial ...

  1. Grid-View-in-IPhone-using-UITableView-1665
  2. GMGridView
  3. UIGridView

I use this below code to display Time-Table with multiple columns, Some code for Example ..

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

I hope this help you...

like image 105
Paras Joshi Avatar answered Jan 31 '23 07:01

Paras Joshi