【问题标题】:Search Icon in string in iphoneiphone中字符串中的搜索图标
【发布时间】:2012-01-07 12:51:39
【问题描述】:

我正在我的应用程序中制作联系人列表类型的视图。如图所示,作为联系人应用程序,字母列表顶部有搜索图标。我也想这样做,但我们不能在这个方法中为 sectionIndexTitlesForTableView 的数组添加图像

所以我需要该图像的那个字符。

有谁知道如何在数组中制作该字符....

提前致谢

【问题讨论】:

标签: iphone objective-c uitableview icons uisearchbar


【解决方案1】:

在数组的开头使用@"{search}",或者简单地使用常量UITableViewIndexSearch(最好)。

【讨论】:

    【解决方案2】:

    正确的答案是 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(抱歉链接,不想复制和粘贴所有内容)。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-06-05
      • 1970-01-01
      • 1970-01-01
      • 2016-11-30
      • 2012-06-25
      相关资源
      最近更新 更多