我是 iphone 的初学者。我需要开发附件中所示的屏幕。所有的值,如机票、飞往纽约的航班、400 美元等都来自数据库。在这个屏幕中,机票、出租车/出租车是显示的类型在不同的单元格中。可以使用一个表视图或多个表视图。请给我建议。
问问题
1346 次
2 回答
4
您不需要制作两个表格视图。因为您可以在单个表视图中实现此功能。将一个 tableView 对象设为...
UITableView *tableView;
在它使部分数量与类别数量(机票,出租车/出租车)一样多之后,您将拥有如下所示: -
- (NSInteger)tableView:(UITableView *)tableView numberOfSections:(NSInteger)section
{
return [category count];
}
在给他们标题之后:-
- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section
{
if (section == 0)
{
return @"header one";
}
}
就是在此之后执行单击某些行的功能:-
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
}
因此,您可以在单个 tableView 中实现您的功能。希望能帮助到你。
于 2012-04-10T16:21:54.277 回答
2
是的,很有可能。您可以创建任意数量的实例(除非内存不足)。您可以通过使用附带的参数区分它们来区分 delgate 方法调用中的 tableViews...
看到这样...
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
if (tableView==tableView1){
//then do something
}else if (tableView==tableView2){
//then do something else.
}
}
希望这会有所帮助... :)
于 2012-04-10T14:06:40.043 回答