我想创建一个类似于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
的一部分,如果你没有UITableView
,那么你就必须从头开始编写整个控件。 - FogmeisterABCD...
。我有一个自定义的表格视图,不是普通的纯表格视图。是否可以用自定义表格视图创建相同的视图? - Krunal