【问题标题】:Search Bar doesn't disappear after segue to new ViewController切换到新的 ViewController 后,搜索栏不会消失
【发布时间】:2016-01-06 19:20:09
【问题描述】:

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()

为了从TableViewControllersegue 到新的View Controller,我使用这个函数:

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

   self.performSegueWithIdentifier("ContentViewCOntroller", sender: self)       
} 

更多细节在这张图片中:

First TableController where I search data

Second ViewControler with SearchBar, which schould disaper, but it still exist

【问题讨论】:

    标签: ios iphone swift uisearchbar uisearchcontroller


    【解决方案1】:

    您需要在执行转场之前设置searchBar.active = false。 (或在prepareForSegue

    【讨论】:

    • 我花了 3 个小时寻找解决这个问题的答案,终于找到了你的答案!非常感谢!!
    猜你喜欢
    • 1970-01-01
    • 2023-03-15
    • 2014-07-15
    • 1970-01-01
    • 1970-01-01
    • 2014-01-25
    • 2014-05-29
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多