iphone:如何在UITableView中制作多列 [英] iphone: how make Multiple Columns in UITableView
本文介绍了iphone:如何在UITableView中制作多列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
可能重复:
如何在UITableView中显示多个列?
我有多行和多列数据。但是iPhone UITableView只包含单列和多行。如何按照Apple的人机界面指南显示我的多列数据?任何想法?
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?
推荐答案
使用GridView满足您的要求,请参阅演示和教程的以下链接...
Use GridView for your this requirement, see this bellow links for the Demos and Tutorial ...
- Grid-View-in-IPhone-using-UITableView-1665
- GMGridView
- 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...
这篇关于iphone:如何在UITableView中制作多列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文