3

In my Application what i'm doing is:

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

From presentModalViewController i want to go to rootViewController Directly.

So what i did is :

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];
    }
}

but here i'm getting a message
Warning: Attempt to dismiss from view controller while a presentation or dismiss is in progress!

and after this app crashes.

I searched about this but couldn't find anything useful for me, Can any body explain why this is happening?

4

1 回答 1

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

这段代码对我来说很好,

重要

viewController必须由navigationController. (在大多数情况下)如果没有,请致电self.presentingViewController.navigationController.

于 2013-09-21T16:02:20.647 回答