我目前设置了UISearchController
,因此点击搜索图标后会显示在导航栏上。
var searchController: UISearchController!
@IBAction func searchMe(sender: UIBarButtonItem) {
// Create the search results view controller and use it for the `UISearchController`.
let searchResultsController = storyboard!.instantiateViewControllerWithIdentifier(SearchResultsViewController.StoryboardConstants.identifier) as! SearchResultsViewController
// Create the search controller and make it perform the results updating.
searchController = UISearchController(searchResultsController: searchResultsController)
searchController.searchResultsUpdater = searchResultsController
searchController.hidesNavigationBarDuringPresentation = false
searchController.searchBar.tintColor = Colors.blue
searchController.searchBar.barTintColor = UIColor.whiteColor()
// Present the view controller.
presentViewController(searchController, animated: true, completion: nil)
}
我使用的是与当前表格视图不同的searchResultsController
来显示结果。问题是当在searchResultsController
中选择一个单元格时,对新的视图控制器(用户配置文件)执行segue
并且没有导航栏。
我需要一个后退按钮才能将用户带回searchResultsController
。我尝试过一堆不同的segues,在故事板上设置导航条但似乎没什么用。我最初的想法是制作这行代码:
searchController = UISearchController(searchResultsController: searchResultsController)
指向导航控制器,searchResultsController
作为其根视图控制器,但我没有运气。任何帮助都很棒!谢谢!