我现在能实现这种效果, 但是如何我想让右侧的这些索引 不管数据源的数据如何都显示A-Z, 想iphone手机通讯录那样, 有什么思路吗
怪我咯2017-04-17 17:48:14
This is officially supported.
- (NSArray *)sectionIndexTitlesForTableView:(UITableView *)tableView {
return @[@"A", @"B", @"C", @"D"……];
}
Can’t we just arrange all 26 letters here?
迷茫2017-04-17 17:48:14
It can be achieved. Check the UITableView Section Index related content and you should be able to find the answer you want.
天蓬老师2017-04-17 17:48:14
You should modify your own data source, because the index label display number is calculated based on the array count of your data source;
You give 26 arrays in your original data source, and then fill the data in the corresponding object;
In this way, you can use the sectionIndexTitlesForTableView method to return an array of 26 English letters and it will be OK.
迷茫2017-04-17 17:48:14
//返回27,是a-z和#
UILocalizedIndexedCollation *indexCollation = [UILocalizedIndexedCollation currentCollation];
[self.titleArray addObjectsFromArray:[indexCollation sectionTitles]];