【问题标题】:Implement UISearchController using objective-C in existing tableview在现有的 tableview 中使用 Objective-C 实现 UISearchController
【发布时间】:2017-08-18 21:18:30
【问题描述】:

我有一个现有的基于 Objective-C 的代码,其中有一个视图控制器具有各种 UItextFileds(一种注册表单)。从这些字段中的 1 个字段中,加载具有 UITableView 的新视图控制器。这个viewcontroller也有搜索框来显示搜索结果,目前使用“searchDisplayController”实现。

我想使用“UISearchController”更改实现,我必须使用这个现有的 TableView(已经以编程方式创建)并在其上实现 UISearchcontoller。请提供一些好的示例/代码来建议这样做。

我在博客中获得了很多示例,但所有示例都在使用 swift 或创建自己的 TableViewContoller。

【问题讨论】:

    标签: ios objective-c uitableview uisearchcontroller


    【解决方案1】:

    在 viewDidLoad 中:

    self.searchController = [[UISearchController alloc] initWithSearchResultsController:nil];
    self.searchController.searchResultsUpdater = self;
    self.searchController.dimsBackgroundDuringPresentation = NO;
    self.searchController.searchBar.delegate = self;
    // To have the search bar appear at the top of the tableView
    self.tableView.tableHeaderView = self.searchController.searchBar;
    self.definesPresentationContext = YES;
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-02-12
      • 1970-01-01
      • 1970-01-01
      • 2012-04-30
      • 1970-01-01
      相关资源
      最近更新 更多