iOS7: How to implement Section Index like Contacts on iOS7?

In iOS7, the Section Index of Contact app shows fewer indexes.

For example, "A ● C ● E ... M ● P ● R..."

iOS7联系人

I know these two delegate methods:

-(NSArray *)sectionIndexTitlesForTableView:(UITableView *)tableView

-(NSInteger)tableView:(UITableView *)tableView sectionForSectionIndexTitle:(NSString *)title atIndex

But I don't know how to implement such an shorter index. Can anyone gives me a hint?

Thanks very much!

--edit--

Take a look at the index: "M ● P ● R...", if I swipe from 'M' to 'P', tableView shows section 'M' then 'N' then 'O' and then 'P', which means it uses three indexes index to 4 sections.

--edit--

All right, this kind of index is automatically generated.

If the frame of table is not large enough to show the index, then the index is shown as a doted index.


That is an automatic behavior of the standard index. The index in Contacts is a normal index with all the chars, but you are using an iPhone 4 or 4s and when there are not enough space some letters are replaced with dots. If you open the app with a iPhone 5 or 5s you will see all the letters.


Could this be what you are looking for ? Hum I've replace dot per heart ;-D

- (NSArray *)sectionIndexTitlesForTableView:(UITableView *)tableView {
    NSMutableArray *ma = [NSMutableArray arrayWithArray:@[@"A",@"♥",@"C",@"♥",@"E"]];
    [ma insertObject:UITableViewIndexSearch atIndex:0]; //add magnifier at top
    return ma; 
}
链接地址: http://www.djcxy.com/p/66864.html

上一篇: UITableViewDelegate和UITableViewDatasource混淆

下一篇: iOS7:如何在iOS7上实现部分索引(如联系人)?