【发布时间】:2013-07-16 10:24:24
【问题描述】:
我想创建一个类似iOS 联系人应用程序的视图,
基本上我想要的是位于右侧的垂直
ABCDEFG....这张图片的一侧,当用户点击字符M我想 获取字符M我应该如何实现这一点?有没有iOS 控件给了我这个 `ABCDEF...?
提前致谢。
编辑
- (NSArray *)sectionIndexTitlesForTableView:(UITableView *)tableView
{
return [[NSArray arrayWithObject:UITableViewIndexSearch] arrayByAddingObjectsFromArray:
[[UILocalizedIndexedCollation currentCollation] sectionIndexTitles]];
}
- (NSInteger)tableView:(UITableView *)tableView sectionForSectionIndexTitle:(NSString *)title atIndex:(NSInteger)index
{
if (title == UITableViewIndexSearch)
{
CGRect searchBarFrame = self.searchDisplayController.searchBar.frame;
[tableView scrollRectToVisible:searchBarFrame animated:YES];
return -1;
}
else {
UILocalizedIndexedCollation *currentCollation = [UILocalizedIndexedCollation currentCollation];
NSLog(@"selected charecter=%ld",(long)[currentCollation sectionForSectionIndexTitleAtIndex:index]);
return [currentCollation sectionForSectionIndexTitleAtIndex:index-1];
}
}
【问题讨论】:
-
你想创建一个带有索引的自定义 UITableView 还是只想展示内置的联系人选择器?
-
我不想创建自定义表格视图,我只想要位于右侧的 ABCDEF...。该控件的名称是什么?是联系人选择器吗??
-
你有一个表格视图,里面有你自己的数据吗?或者您正在使用联系人选择器?请说明您想做什么,否则我们不知道。您所指的控件是
UITableView的一部分,如果您没有UITableView,那么如果不自己从头开始编写整个内容,您将无法获得它。 -
我只想要突出显示的部分
ABCD...我有 tablview 但它是自定义的 tableview 而不是普通的普通 tableview。是否可以使用自定义 tableview 创建相同的视图? -
所以,当我问“你想创建一个带有索引的自定义 UITableView”并且你说“不”时,你的实际意思是“是”。谷歌搜索“UITableView index”有数百个例子。