我正在构建一个 iOS 应用程序,我正在使用地址簿中的信息。我正在显示地址簿中的所有数据以及一些自定义信息,但我遇到了一个小问题。
我的问题是章节索引标题。首先,我尝试返回一个包含所有字母的数组,但这让我的工作看起来很奇怪。我想让我的应用程序中的部分索引标题看起来与联系人应用程序中的一样,带有蓝点,如下图所示
抱歉,我无法上传图片,它说我需要 10 个代表才能上传
我再说一遍,我希望我的应用程序具有与“通讯录”应用程序相同的部分索引标题和蓝点。
谢谢
这是我的代码
NSArray *alphabets =[[NSArray alloc] initWithObjects:@"A",@"B",@"C",@"D",@"E",@"F",@"G",@"H",@"I",@"J",@"K",@"L",@"M",@"N",@>"O",@"P",@"Q",@"R",@"S",@"T",@"U",@"V",@"W",@"X",@"Y",@"Z", nil];
- (NSArray *)sectionIndexTitlesForTableView:(UITableView *)tableView {
return alphabets;
}
最佳答案
你应该看看
填充索引列表部分。
- (NSArray *)sectionIndexTitlesForTableView:(UITableView *)tableView {
return [[UILocalizedIndexedCollation currentCollation] sectionIndexTitles];
}
- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section {
if ([[self.states objectAtIndex:section] count] > 0) {
return [[[UILocalizedIndexedCollation currentCollation] sectionTitles] objectAtIndex:section];
}
return nil;
}
- (NSInteger)tableView:(UITableView *)tableView sectionForSectionIndexTitle:(NSString *)title atIndex:(NSInteger)index
{
return [[UILocalizedIndexedCollation currentCollation] sectionForSectionIndexTitleAtIndex:index];
}
关于ios - 如何获得与 iPhone 上的联系人应用程序相同的部分索引标题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21237774/