【发布时间】:2012-01-07 12:51:39
【问题描述】:
我正在我的应用程序中制作联系人列表类型的视图。如图所示,作为联系人应用程序,字母列表顶部有搜索图标。我也想这样做,但我们不能在这个方法中为 sectionIndexTitlesForTableView 的数组添加图像
所以我需要该图像的那个字符。
有谁知道如何在数组中制作该字符....
提前致谢
【问题讨论】:
标签: iphone objective-c uitableview icons uisearchbar
我正在我的应用程序中制作联系人列表类型的视图。如图所示,作为联系人应用程序,字母列表顶部有搜索图标。我也想这样做,但我们不能在这个方法中为 sectionIndexTitlesForTableView 的数组添加图像
所以我需要该图像的那个字符。
有谁知道如何在数组中制作该字符....
提前致谢
【问题讨论】:
标签: iphone objective-c uitableview icons uisearchbar
在数组的开头使用@"{search}",或者简单地使用常量UITableViewIndexSearch(最好)。
【讨论】:
正确的答案是 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”中添加了一些额外的 cmets(抱歉链接,不想复制和粘贴所有内容)。
【讨论】: