我有一个显示城市列表的UITableView . 我想把它们按国家分开 . 我似乎无法弄清楚如何从我的阵列中选择正确的项目 . 如果第1节(亚利桑那州)有2个城市而第2节(加利福尼亚州)有2个城市,则在cellForRowAtIndexPath第2节中,城市1的索引为0,即使它是我的数组中的第3个项目 . 我想过把我的城市阵列变成一个状态阵列,每个项目都有一个城市阵列,但我仍然不知道我在哪个部分,因此不知道状态数组下的哪个城市数组我会需要访问 .
任何帮助,将不胜感激 .
该方法被调用
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
indexpath参数包含row和section属性 .
indexPath.section indexPath.row
这是文档链接
NSIndexPath班
NSIndexPath UIKit Additions添加的section,row和item属性 .
你可以使用 indexPath.section 和 indexPath.row
indexPath.section
indexPath.row
2 回答
该方法被调用
indexpath参数包含row和section属性 .
这是文档链接
NSIndexPath班
NSIndexPath UIKit Additions添加的section,row和item属性 .
你可以使用
indexPath.section
和indexPath.row