Warning: Attempt to dismiss from view controller <UINavigationController: 0xb359a20> while a presentation or dismiss is in progress

StackOverflow https://stackoverflow.com/questions/18934342

Frage

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?

War es hilfreich?

Lösung

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

This code work fine for me,

Important:

the viewController must be presented by the navigationController. (In most cases) If not, call self.presentingViewController.navigationController.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top