带有索引的iPhone uitableview可以使用每个不同的单元格推出不同的详细视图?
-
02-10-2019 - |
题
我知道可以创建一个表,该表在侧面有索引,在顶部的搜索栏可以输入以查找项目,但是如果数组等于“ item1” push查看1?我想用每个单元格推出不同的视图。有人有建议吗?
解决方案
基于索引路径创建单元格。如果您提前创建所有单元格,请将它们存储在行索引中。如果您根据需要创建它们,请执行这样的操作:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
UITableViewCell *result;
switch ( [indexPath row] ) {
default: result = [self tableView:tableView normalCellForRowAtIndexPath:indexPath]; break;
case 3: result = [self tableView:tableView detail3CellForRowAtIndexPath:indexPath]; break;
case 5: result = [self tableView:tableView detail5CellForRowAtIndexPath:indexPath]; break;
}
return result;
}
其他提示
当然。只需根据单元格创建适当的视图(控制器) indexPath
在 tableView:didSelectRowAtIndexPath:
.
查看本书中iPhone开发的示例程序。您必须注册,但免费。您应该专门查看第9章的示例代码,称为NAV。向您显示您需要的东西。这是我关于该主题的第一本书,非常值得。
http://www.iphonedevbook.com/forum/viewforum.php?sid=3010C045DF967353C6B389489E6B8F5
干杯!肯
不隶属于 StackOverflow