0

I have 3 view controllers, A, B and C. B is presented on A. What I need is to present C on A when a button clicked on B and dismiss B. But I am unable to do so. Is there some workaround. Thanks for help.

Adnan
  • 5,025
  • 5
  • 25
  • 44
  • What do you want to happen to B at this point? – rmaddy Feb 20 '14 at 01:47
  • B should be dismissed. – Adnan Feb 20 '14 at 01:48
  • Using a delegate setup, have B send a message to A (via the delegate) indicating that A should dismiss B and then display C. – rmaddy Feb 20 '14 at 01:49
  • A is not a single viewcontroller. B can be presented on any viewcontroller of my application. It is good idea to setup delegate in a parent viewcontroller and extend others from it but due to specific kind of application, I cant extend all viewcontrollers to single viewcontroller. – Adnan Feb 20 '14 at 01:53
  • 1
    `dismissViewControllerAnimated:completion:` - the completion could work to your advantage in this situation – Max Chuquimia Feb 20 '14 at 02:02
  • Jugale I have tried this but it also not working in this case. – Adnan Feb 20 '14 at 02:07
  • Once the view controller B is dismissed, present the view controller C after some delay (0.5). – RAJA Feb 20 '14 at 02:24

3 Answers3

2

click the button on B, in iOS5,

UIViewController *presentingVC = self.presentingViewController;
[self dismissViewControllerAnimated:YES completion:^{
      [presentingVC presentViewController:vc3 animated:YES completion:nil];
}];
simalone
  • 2,768
  • 1
  • 15
  • 20
1

when you clicked the button on B, pop B itself and use NSNotificationCenter to gave a notification to A,make A to push C.

feng20068
  • 11
  • 3
1

If you don't want to setup a delegate just get A through the property presentingViewController inside B, call the desired method of A, in that method first dismiss modal controller and then present C.

dev gr
  • 2,409
  • 1
  • 21
  • 33