0

我在以下代码中遗漏了什么?我可以创建一个列表,但该列表是数组 x26 倍(26x 部分)UITableView。显示列表,但部分标题仅指向“A”

在此处输入图像描述

arr_indexpeople> A、B、C、D、E.....Z 的数组

arr_completeArray> 一组人员列表

谢谢你。

4

3 回答 3

4

返回 [arr_indexpeople objectAtIndex:section]

于 2013-01-24T05:05:47.987 回答
3

您在 titleForHeaderInSection 中返回 objectAtIndex 0。改成——

- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section
{
      return [arr_indexpeople objectAtIndex:section]
}
于 2013-01-24T05:14:21.050 回答
2

每个要加载的部分都会调用数据源方法,因此将部分的动态索引作为 arr_indexpeople 的输入变量,如下所示。

- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section
{
  return [arr_indexpeople objectAtIndex:section]
}
于 2013-01-24T06:04:54.297 回答