I am working application in which i calling presentModalViewController
and once finished(calling dismissModalViewControllerAnimated:YES
) it should immediately call popToRootViewControllerAnimated
.
But the issue is dismissModalViewControllerAnimated:YES
is working properly but popToRootViewControllerAnimated
is not working after it.
The code is shown below:
[self.navigationController dismissModalViewControllerAnimated:YES] ;
[self.navigationController popToRootViewControllerAnimated:YES];
Try something like this:
[self.navigationController dismissModalViewControllerAnimated:YES] ;
[self performSelector:@selector(patchSelector) withObject:nil afterDelay:0.3];
-(void)patchSelector{
[self.navigationController popToRootViewControllerAnimated:YES];
}
It is not so neat but it should work.
UPDATE: You should use
[self dismissModalViewControllerAnimated:YES];
instead
[self.navigationController dismissModalViewControllerAnimated:YES] ;
The object that is presenting the modal is the view controller, not the navigation controller.
If you have a navigation controller with a stack of UIViewControllers:
[self dismissModalViewControllerAnimated:YES];
[(UINavigationController*)self.parentViewController popToRootViewControllerAnimated:YES];
//UIViewController *vc = [[UIViewController new] autorelease];
//[(UINavigationController*)self.parentViewController pushViewController:vc animated:YES];
Assumes, that view controller in which called modal view controller has navigationController.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With