尝试在MasterViewController的表的标题上添加搜索栏(UISearchController)时遇到问题。
ios - MasterViewController(UISplitViewController)上UISearchBar下的UITableView-LMLPHP
ios - MasterViewController(UISplitViewController)上UISearchBar下的UITableView-LMLPHP
如您所见,表格位于搜索栏下方。
关于如何解决此问题的任何想法?

这是我用于MasterViewController的代码

private var searchController : UISearchController = ( {
    let controller = UISearchController(searchResultsController: nil)
    controller.dimsBackgroundDuringPresentation = false
    controller.searchBar.sizeToFit()
    return controller
})()

override func viewDidLoad() {
    super.viewDidLoad()
    navigationController?.navigationBar.translucent = false

    self.edgesForExtendedLayout = .None
    self.extendedLayoutIncludesOpaqueBars = false
    self.automaticallyAdjustsScrollViewInsets = false

    searchController.searchResultsUpdater = self
    searchController.searchBar.delegate = self
    self.tableView.tableHeaderView = searchController.searchBar

    if let split = self.splitViewController {
        let controllers = split.viewControllers
        self.detailViewController = (controllers[controllers.count-1] as! UINavigationController).topViewController as? DetailViewController
    }
}

最佳答案

打开情节提要,选择视图控制器,然后在属性检查器中,取消选中中的Under Top Bars,在View Controller组

10-08 08:06