开发者

Wrong indexing for sectionIndexTitlesForTableView

I am using a list that can be sorted in various ways, regenerating the UITableView each time the sort-order is changed.

I set the sectionIndex each time the same way, which is:

- (NSArray *)sectionIndexTitlesForTableView:(UITableView *)tableView {
    return [NSArray arrayWithObjects:@"•", @"•", @"•", @"•", @"•", @"•", @"•", @"•", @"•", @"•", nil];
}

Trouble is that when after I change the sort order (lets say from country to city name), the index doesn't work properly anymore.

It almost seems that the index doesn't recognize that the tableview h开发者_运维百科as a different number of sections.

Any ideas where I might find the right screw for this?

Cheers


Try this logic in your code.

NSInteger section = [IndexPath section];

if (section ==0)
    // return sorted array for that section (1st section)

if (section ==1)
    // return sorted array for that section (2nd section)


See Sergio's comment:

  • are you implementing tableView:sectionForSectionIndexTitle:atIndex ?

That did it ...

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜