我有一个UITableViewController
,其中包括UISearchController
。然后,这将切换到UIViewController
,然后是另一个UIViewController
。从第二个视图开始,我想通过首先隐藏UISearchController然后弹出两个视图来转换回UITableViewController
。
为了实现这一点,我有:
var stackViews = self.navigationController?.viewControllers.count
var musicTableController = self.navigationController?.viewControllers[stackViews!-3] as! MusicTableController
musicTableController.resultSearchController.active = false
self.navigationController?.popToViewController(musicTableController, animated: true)
然而,这会导致错误
popToViewController:transition: called on <UINavigationController 0x7fb42a575550> while an existing transition or presentation is occurring; the navigation stack will not be updated.
我猜我需要在resultsSearchController转换完成之后弹出视图。
Swift,ios8,xcode6.4
您可以在dismiss(_:_:)
上调用UISearchController
,而不是将isActive
设置为false。
if searchController.isActive {
self.searchController.dismiss(animated: true, completion: {
// Play segue, dismiss or pop ...
})
} else {
// Play segue, dismiss or pop ...
}