【问题标题】:What’s the correct way to “hook up” the magnifying glass icon in a UITableView?在 UITableView 中“连接”放大镜图标的正确方法是什么?
【发布时间】:2012-02-18 01:15:03
【问题描述】:

我有一个 UITableViewController,其中包含一个用于搜索的 UISearchBarController。我有所有的搜索功能,而且工作正常,但我想遵循搜索栏的通常约定,可以从部分索引中的放大镜图标访问。我知道我可以通过在sectionIndexTitlesForTableView: 返回的数组中包含UITableViewIndexSearch 来获取图标,但是当用户点击放大镜时如何滚动到搜索栏?我想我需要在tableView:sectionForSectionIndexTitle:atIndex: 中添加一些内容,但我不知道是什么,因为(据我所知)搜索控制器实际上并不在表格的任何部分中。

【问题讨论】:

    标签: ios cocoa-touch uitableview uisearchdisplaycontroller


    【解决方案1】:

    我在tableView:sectionForSectionIndexTitle:atIndex: 中执行以下操作来显示搜索栏。第一条语句为搜索栏设置动画,第二条语句向上滚动到第一部分。

    if ([title isEqualToString:UITableViewIndexSearch]) 
    {
        [self.searchController setActive:TRUE animated:TRUE];
        return 0;
    }
    

    【讨论】:

      猜你喜欢
      • 2010-09-19
      • 2014-05-08
      • 2014-07-04
      • 1970-01-01
      • 2012-04-08
      • 2011-03-21
      • 1970-01-01
      • 1970-01-01
      • 2011-10-08
      相关资源
      最近更新 更多