MasterViewController上的UISearchBar下的UITableView(UISplitViewController)

时间:2016-08-01 19:00:58

标签: ios swift uisplitviewcontroller uisearchcontroller

尝试在MasterViewController表的标题上添加搜索栏(UISearchController)时遇到问题。 Initial state Search selected 如您所见,该表位于搜索栏下方。 关于如何解决这个问题的任何想法?

这是我用于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
    }
}

1 个答案:

答案 0 :(得分:0)

打开故事板,选择视图控制器,然后在属性检查器中,取消选中查看控制器组

中的Under Top Bars