1

I have view controllers A, B, C, D. Current view controller is A.

I need to present D from A. And then when I dismiss D I should see C. When I dismiss C, I should see B.

It's easy to implement with navigation controller stack, but I don't know if it's possible to implement this with modal view controllers stack.

Paul T.
  • 4,938
  • 7
  • 45
  • 93
  • What did you try so far? – meaning-matters Aug 30 '13 at 11:29
  • The best solution I see right now is to present without animation B from A, then present without animation C from B, and then D from C. So user will see only D without animation, but behavior with animation is better – Paul T. Aug 30 '13 at 11:34
  • In my opinion the thing to think about here is not can you do this, but **should** you do this. The view hierarchy is important so the user understands where they are in your app. If the user goes from view A to view B, they expect that when they go back, they'll get back to view A. Unless your app has a clear indication that this won't be the case I wouldn't recommend going down this route from a usability point of view. – Steve Wilford Aug 30 '13 at 11:39

1 Answers1

0

Yes, First set property to those all view controller I mean like: @property (nonatomic,strong) UIViewController * viewa,*viewb,*viewc,*viewd;

You can switch the viewcontroller like:

[self presentViewController: viewb animated:NO completion:nil];

So add this statement from wherever you want to change the viewcontroller.

Try this.

I am doing the same in my app and its working.

Or when u want to dismiss view then use this:-

[[self presentingViewController] dismissViewControllerAnimated:YES completion:nil];

Shyam Dixit
  • 2,325
  • 3
  • 19
  • 27