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?
[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
.