UILocalizedIndexedCollation locale different than

2019-07-27 04:31发布

I am using Tableview with UILocalizedIndexedCollation to show the index on right side but the language on my phone is Swedish (svenska) hence I see some special characters specific to Swedish language like å ä ö after A-Z . In A-Z some of the characters are missing like Q, X etc which I believe are not there in Sweidsh locale.

I am facing issue when I click say character "S" , it shows me section "R" instead of "S" even though there are entries in "S" . Also for last characters "å", "ä" it takes me to X and Y respectively , although there is no "X" in the LocalizedIndexedCollation.

I followed this tutorial too http://benedictcohen.co.uk/blog/archives/230 but it did not fixed my issue.

Any help on this would be great.

Thanks.

1条回答
虎瘦雄心在
2楼-- · 2019-07-27 05:18

Same in Korean with iOS7 GM.

I checked Japanese either, but there isn't the problem we facing.
The difference between Japanese and Korean is the ordering(link)

In Korean, Korean occurs before English.
But in Japanese, English occurs before Japanese when I tested.

When I check this method,

- (NSInteger)tableView:(UITableView *)tableView sectionForSectionIndexTitle:(NSString *)title atIndex:(NSInteger)index
{
    NSLog(@"%i", index);
    NSLog(@"%i", [[UILocalizedIndexedCollation currentCollation] sectionForSectionIndexTitleAtIndex:index]);
}

I can notice sectionForSectionIndexTitleAtIndex increasing in accordance with given index abnormally. Korean ordering

  • sectionForSectionIndexTitleAtIndex increase 4 ("A" + 1 - "F"), when "ㄴ" -> "ㄷ" (index increase just 1).
  • Increment of sectionForSectionIndexTitleAtIndex is repeating. 1, 4, 1, 4 ...

My conclusion about this problem is that iOS7 bug in Unicode with ASCII ordering.
So, I will temporarily modify tableView:sectionForSectionIndexTitle:atIndex method works as I intended.

查看更多
登录 后发表回答