Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Dismiss presenting view controller

I have the following situation:

view controller A -> presents modally -> view controller B

view controller B -> presents modally -> view controller C

I would like to dismiss view controller "C" and go directly to "A" instead of showing "B" since it do not make sense to show "B" at that time.

How can I accomplish that ?

Thanks, Daniel

like image 572
danflu Avatar asked Oct 30 '14 19:10

danflu


2 Answers

In 'view controller C' ->

Before iOS 6: Use

[self.parentViewController.parentViewController dismissModalViewControllerAnimated:YES];

Or,

[self.presentingViewController.presentingViewController dismissModalViewControllerAnimated:YES];

From and Above iOS 6: Use

[self.presentingViewController.presentingViewController dismissViewControllerAnimated:YES completion:nil];
like image 190
Asif Asif Avatar answered Oct 09 '22 13:10

Asif Asif


You can use segues to present view controllers from other view controllers.

To go backwards through a hierarchies you normally dismiss presented view controllers or you go back to specific view controllers through unwind segues.

like image 44
Abizern Avatar answered Oct 09 '22 13:10

Abizern