在segue到新的ViewController之后,搜索栏不会消失

Pit*_*Pan 1 iphone uisearchbar ios swift uisearchcontroller

Search Bar塞维到新的后不想消失ViewController.我创建search bar它:

    self.searchBar = UISearchController(searchResultsController: nil)
    self.searchBar.searchResultsUpdater = self
    self.searchBar.dimsBackgroundDuringPresentation = false


    self.navigationController?.extendedLayoutIncludesOpaqueBars = true
    self.tableView.tableHeaderView = self.searchBar.searchBar
    self.tableView.reloadData()
Run Code Online (Sandbox Code Playgroud)

for segue to new View Controllerfrom TableViewControllerI使用此函数:

    override func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {

   self.performSegueWithIdentifier("ContentViewCOntroller", sender: self)       
} 
Run Code Online (Sandbox Code Playgroud)

这张照片中的更多细节:

我搜索数据的第一个TableController

第二个带有SearchBar的ViewControler,它可能会降低成本,但它仍然存在

tsk*_*bru 5

您需要searchBar.active = false在执行segue之前进行设置.(或者在prepareForSegue