ios导航堆栈中的两个转换/演示文稿

时间:2015-08-22 13:39:44

标签: ios swift uiviewcontroller uinavigationcontroller uisearchcontroller

我有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

1 个答案:

答案 0 :(得分:1)

您可以在dismiss(_:_:)上致电UISearchController,而不是将isActive设为false。

if searchController.isActive {
    self.searchController.dismiss(animated: true, completion: {
        // Play segue, dismiss or pop ...
    })
} else {
   // Play segue, dismiss or pop ...
}
相关问题