[英]Back to root viewController from UISearchController Cancel-Button
I have a simple app which contains a UISearchController
within a tableView (bottom view in the screenshot). 我有一个简单的应用程序,该应用程序在tableView(屏幕快照的底部视图)中包含一个UISearchController
。
The initial segue works fine, the UISearchController
becomes visible after the barButton (lupe-icon) was hit. 最初的搜索工作正常,击中barButton(lupe-icon)后, UISearchController
变为可见。
But now I want to hide that SearchTableView when the user hits the Cancel-Button of the searchController (the app should return to the initial viewController). 但是现在我想在用户点击searchController的“取消”按钮时隐藏该SearchTableView(应用程序应返回到初始viewController)。 I tried the following 我尝试了以下
func didDismissSearchController(searchController: UISearchController) {
// cancel?
self.navigationController?.popViewControllerAnimated(true)
}
... but nothing happens. ...但是什么也没发生。 So how can I return to the root viewController from this point? 那么,如何从这一点返回到根viewController呢?
Try to dismiss the search bar first: 尝试先关闭搜索栏:
func didDismissSearchController(searchController: UISearchController) {
searchController.active = false
self.navigationController?.popViewControllerAnimated(true)
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.