popViewController:动画:在iOS 9中不起作用

ZeM*_*oon 2 objective-c uiviewcontroller uinavigationcontroller ios ios9

我正在使用一个子类UINavigationController,它管理我的应用程序中的所有viewControllers.它在主流中推送和弹出viewControllers,并以模态方式呈现和解散那些任意需要的viewControllers.

在一种情况下,我需要在主流中弹出另一个之前以模态方式呈现一个viewController,如下所示:

//Called in custom UINavigationController subclass
[self presentViewController:searchVC animated:YES completion:^{
    [self popViewControllerAnimated:NO]; 
}];
Run Code Online (Sandbox Code Playgroud)

以上代码用于在iOS 8中顺利工作,并且在iOS 9中不起作用.当呈现的vc被解除时,与之前相同的viewController仍然存在.

此外,这是在控制台中记录:

popViewControllerAnimated: called on <CustomNavigationController 0x7d846600> while an existing transition or presentation is occurring; the navigation stack will not be updated.
Run Code Online (Sandbox Code Playgroud)

到目前为止,这从来都不是问题,特别是因为在完成块中调用了popViewController方法.

这可能是个错误吗?

欢迎任何解决方案/建议/解决方法.

ZeM*_*oon 7

在一个dispatch_async块中包装popViewController调用.

[self presentViewController:searchVC animated:YES completion:^{
    dispatch_async(dispatch_get_main_queue(), ^{
        [self popViewControllerAnimated:YES];
    }); 
}];
Run Code Online (Sandbox Code Playgroud)