ios - 警告 : Attempt to dismiss from view controller <UINavigationController: 0xb359a20> while a presentation or dismiss is in progress

标签 ios objective-c uinavigationcontroller presentmodalviewcontroller poptoviewcontroller

在我的应用程序中我正在做的是:

rootViewController -> pushViewController -> pushViewController -> pushViewController -> presentModalViewController

我想从 presentModalViewController 直接转到 rootViewController。

所以我所做的是:

while(theViewController = [theObjectEnumerator nextObject ])
     {
         if([theViewController modalTransitionStyle] == UIModalTransitionStyleCoverVertical)
         {
             [self.mNavigationController popToRootViewControllerAnimated:
              YES];
         }
     }
 }else
while(theViewController = [theObjectEnumerator nextObject ])
{
    if([theViewController modalTransitionStyle] == UIModalTransitionStyleCoverVertical)
    {
        [self.mNavigationController dismissModalViewControllerAnimated:YES];
    }
}

但是我收到一条消息
警告:在演示或解散过程中尝试从 View Controller 中解散!

在这个应用程序崩溃之后。

我搜索了这个但找不到对我有用的东西, 谁能解释为什么会这样?

最佳答案

[self dismissViewControllerAnimated:YES completion:^{
    [(UINavigationController *)self.presentingViewController popToRootViewControllerAnimated:YES];
}];

这段代码对我来说很好,

重要:

viewController 必须由 navigationController 呈现。 (大多数情况下) 如果没有,调用 self.presentingViewController.navigationController

关于ios - 警告 : Attempt to dismiss from view controller <UINavigationController: 0xb359a20> while a presentation or dismiss is in progress,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18934342/

相关文章:

ios - 将 Dictionary 对象数组存储在 CoreData 中

ios - iPad 上的 UIScrollView 崩溃应用程序

ios - iOS7中拦截后退导航

iphone - IOS 5 - 从另一个 ViewController 调用一个 ViewController

objective-c - 用于 UITableViewCell 的 backgroundView 的初始框架

ios - 是否可以在增强现实应用程序中使用 UILabel 等自定义 iOS UI 元素

objective-c - 在没有子类化的情况下获取 NSSearchField 上的功能键

ios - 如何在控制中心显示搜索轨道持续时间

ios - 具有半透明效果的导航 Controller

ios - 分手了超大类(class),现在出现 segue 错误 [swift]