In my root UIViewController I present a UINavigationController. The UINavigationController ultimately pushes another view (let's call it MyViewController). How can I dismiss the entire UINavigationController (and the views it has pushed) from MyViewController?
From MyViewController, I've tried calling [[self.navigationController presentingViewController] dismissViewControllerAnimated:NO completion:nil]
but nothing happend. I've also tried first popping all the view controllers off the navigation controller but, still, the navigation controller was not dismissed.
Thanks!
UPDATE:
I've tracked down what's causing this issue but haven't been able to solve it. The UINavigationController described above is a custom subclass of UIImagePickerController (we'll call it CameraController) with source type UIImagePickerControllerSourceTypeCamera. Everything works as expected (using the answer provided below) until I set a custom cameraOverlayView
on the CameraController in viewDidLoad
. Commenting out the following lines gets things working:
self.showCameraControls = NO;
UIView *overlay = [[[NSBundle mainBundle] loadNibNamed:@"CameraController" owner:self options:nil] objectAtIndex:0];
self.cameraOverlayView = overlay;
[self dismissModalViewControllerAnimated:YES];
should work – u.gen[self presentViewController:navigationController animated:NO completion:nil]
. The modal stuff is deprecated in iOS6. – scttnlsndismissViewController
just on the navigation controller itself? Also, are you sureself.navigationController
isn't nil? – Dan F[self presentingViewController]
and[self.navigationController presentingViewController]
... do they both return the same object? – foundry