UISearchController - 警告:在演示或解散过程中尝试从视图控制器中解散

UISearchController - Warning: Attempt to dismiss from view controller while a presentation or dismiss is in progress

我有一个可搜索的 table 视图控制器(使用 UISearchController 和 NSFetchedResultsController),它列出了项目行。

它让用户点击一行到 select 项目,这会调用前一个 table 视图的展开转场。

当用户单击一行时,我希望将 selected FetchedResultsController 对象发送回原始 table 视图控制器并填充原始 table 中的一个字段查看并关闭当前可搜索的 table 视图控制器。

当我在没有 搜索的情况下单击 select 项目 的行时,它工作正常,没有任何警告。

但是,当我搜索 table 然后 select 时,我会从显示的过滤项目中搜索带有以下警告:

警告:在演示或关闭过程中尝试从视图控制器关闭!

unwind segue 在情节提要中从 table 视图单元连接到同一 table 视图控制器上的 "Exit" 图标。这是展开转场的代码:

override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject!) {
    if segue.identifier == "myUnwindSegue" {

        let indexPath = tableView.indexPathForSelectedRow
        selectedAirfield = frc.objectAtIndexPath(indexPath!) as? Airfields
        self.navigationController?.popViewControllerAnimated(true)

    }
}

我也试过:

if !self.isBeingDismissed() {
    self.navigationController?.popViewControllerAnimated(true)
}

但这给了我与上面相同的警告。

我也试过:

self.dismissViewControllerAnimated(true, completion: nil)

但这只会让我回到当前的 table 视图,不会让我回到之前的 table 视图控制器,并给我以下警告:

popToViewController:transition:在现有的过渡或演示发生时调用;导航堆栈将不会更新。

我也试过在可搜索的table视图控制器上禁用动画,但这没有效果。

我也试过放置:

self.searchController?.loadViewIfNeeded()

在 viewDidLoad 中也尝试过:

 deinit{
    if let superView = resultSearchController.view.superview {
        superView.removeFromSuperview()
    }
 }

这两个都不能解决问题

重申一下,它仅在 select 搜索结果时发生,并且在 select 未过滤的 table 查看行时完美运行。

我在 Xcode 7.2.1.

感谢任何帮助。

您正在尝试同时推送和弹出相同的 ViewController。当 select 一个项目时你想做什么?

好的,我找到了问题,它可能会对其他人有所帮助。

我在 didSelectRowAtIndexPath 方法中有以下内容:

self.resultSearchController.active = false

因此,当我通过选择行关闭视图时,我试图停用显然涉及 animation/presentation

的 UISearchController

通过删除此行,警告已停止。