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 ...
精彩评论