ios - 请教一个tableview 右侧索引实现的思路
高洛峰
高洛峰 2017-04-17 17:46:14
0
4
318


我现在能实现这种效果, 但是如何我想让右侧的这些索引 不管数据源的数据如何都显示A-Z, 想iphone手机通讯录那样, 有什么思路吗

高洛峰
高洛峰

拥有18年软件开发和IT教学经验。曾任多家上市公司技术总监、架构师、项目经理、高级软件工程师等职务。 网络人气名人讲师,...

reply all(4)
刘奇

This is officially supported.

- (NSArray *)sectionIndexTitlesForTableView:(UITableView *)tableView {
    return @[@"A", @"B", @"C", @"D"……];
}

Can’t we just arrange all 26 letters here?

迷茫

It can be achieved. Check the UITableView Section Index related content and you should be able to find the answer you want.

Peter_Zhu

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.

迷茫
//返回27,是a-z和#
UILocalizedIndexedCollation *indexCollation = [UILocalizedIndexedCollation currentCollation];     
[self.titleArray addObjectsFromArray:[indexCollation sectionTitles]];      
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template