ios - 如何获得与 iPhone 上的联系人应用程序相同的部分索引标题

标签 ios objective-c cocoa-touch ios7

我正在构建一个 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;
}

图片链接是http://tinypic.com/r/70u93s/5

最佳答案

你应该看看

https://developer.apple.com/library/ios/documentation/UserExperience/Conceptual/TableView_iPhone/CreateConfigureTableView/CreateConfigureTableView.html

填充索引列表部分。

- (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/

相关文章:

ios - Swift 获取字符串中两个字符串之间的字符串

ios - 将数据从一个 ViewController 传递到另一个 ViewController 时应用程序崩溃

iPhone - UIImageView 中的图像不显示在模拟器中

ios - 在核心数据中访问我的托管对象的 NSSet

ios - 来自 WebApi 应用程序的 Apple 推送通知

ios - 多线程在swift ios中并行执行多个任务

iphone - 使用 UIActivityViewController 附加本地视频

ios - _tableView reloadData 使我的应用程序崩溃

iphone - 左右滑动 UIView

iphone - 如何在 iPhone Sdk 中开始自动录制视频