我正在申请中制作联系人列表。作为联系人应用程序,字母表列表顶部有搜索图标,如图所示。我想这样做,但我们无法在此方法中为sectionIndexTitlesForTableView添加数组中的图像
所以我需要那个图像的特征。
是否有人知道如何在数组中创建该字符....
提前致谢
答案 0 :(得分:5)
在数组的开头使用@"{search}"
,或只使用常量UITableViewIndexSearch
(最佳)。
答案 1 :(得分:0)
正确的答案是 UITableViewIndexSearch ,App Store中提供的应用程序示例代码:
- (NSArray *)sectionIndexTitlesForTableView:(UITableView *)tableView
{
NSMutableArray *titles = [NSMutableArray arrayWithCapacity:[self.myList count]+1];
[titles addObject:UITableViewIndexSearch];
if (tableView == self.searchDisplayController.searchResultsTableView)
{
for (NSString *item in self.filteredList)
[titles addObject:[item substringToIndex:1]];
}
else
{
for (NSString *item in self.myList)
[titles addObject:[item substringToIndex:1]];
}
return titles;
}
我的博客文章“How to Get Magnifying Glass into UITableView Index”中很少有其他评论(对于链接感到抱歉,不想复制和粘贴所有内容)。