Is this different in different locales? I'm completely failing to understand what the point of the sectionForSectionIndexTitleAtIndex
method on UILocalizedIndexCollation
is. Every index I pass just returns the identical index.
The documentation is not very helpful at all, and I can't seem to find any instance where the number it returns is different than the number I supply it. Why not just return the number itself?
Worse, if I add additional indices to my table view, such as UITableViewIndexSearch
and some custom ones, so that in total my table view's section index titles have the search character, two custom ones, letters of the alphabet and # (for a total of 30 section titles), I have no idea what to pass into sectionForSectionIndexTitleAtIndex
from UITableViewDataSource
's sectionForSectionIndexTitle:atIndex:
method!
If I pass the index the table view method gives me (say 1), it'll give me 1 back, which is wrong, because if I tap on the section index 1, it should jump to the first custom one. So I should only start once the alphabet part starts, which starts at section index 3. But if I pass 3 into the sectionForSectionIndexTitleAtIndex
method, I get 3 back, when I should be getting 2 back, because the search character isn't an actual section.
So I should only start after 3, at which point I subtract 1 to get the actual index. Okay. Then I get to the last section index, the #, at index 29. I pass 29 - 1 (which is 28) to sectionForSectionIndexTitleAtIndex
and I then get an error that it's out of the bounds, because there's only 27 characters.
How on earth should I be using it in this case? It seems completely useless, and I feel like just returning the index. But does this break under certain locales? How does this method work?