我在以下代码中遗漏了什么?我可以创建一个列表,但该列表是数组 x26 倍(26x 部分)UITableView
。显示列表,但部分标题仅指向“A”
arr_indexpeople
> A、B、C、D、E.....Z 的数组
arr_completeArray
> 一组人员列表
谢谢你。
我在以下代码中遗漏了什么?我可以创建一个列表,但该列表是数组 x26 倍(26x 部分)UITableView
。显示列表,但部分标题仅指向“A”
arr_indexpeople
> A、B、C、D、E.....Z 的数组
arr_completeArray
> 一组人员列表
谢谢你。
返回 [arr_indexpeople objectAtIndex:section]
您在 titleForHeaderInSection 中返回 objectAtIndex 0。改成——
- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section
{
return [arr_indexpeople objectAtIndex:section]
}
每个要加载的部分都会调用数据源方法,因此将部分的动态索引作为 arr_indexpeople 的输入变量,如下所示。
- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section
{
return [arr_indexpeople objectAtIndex:section]
}