0
votes

I have such flow

navigationController-viewContorller

and at viewController I have switch that can present 3 other viewControllers modally. They will be presented separately and at the moment the only one of them can be on the screen. (Every viewController has the same switch that can present other viewController).

 modal-viewContorller1
 modal-viewContorller2
 modal-viewContorller3

How can I do that? I have a common class for the switch that will present other viewControllers. But as they are presented modally, I can not go through already presented viewControllers to dismiss some of them. (I need only one of three modal viewControllers on the screen at the moment).

Also I present every modal viewController with navigationController:

 UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:self.userInterface];
 [navigationController setNavigationBarHidden:YES];

How can I achieve that flow?

1
there won't be multiple view controllers at any point!!!! There will be only one!!!! What is your exact question ? - Teja Nandamuri

1 Answers

0
votes

If I read you correctly, you have switches to present the 3 modal viewControllers in your root viewController as well as each of the modal viewControllers.

1) when you want to present a modal VC from your root VC, use:

[self presentViewController:modal-viewContorller1 animated:YES completion:NULL];

if a VC is already presented :

[self dismissViewControllerAnimated:YES completion:nil];
[self presentViewController:modal-viewContorller1 animated:YES completion:NULL];

2) when presenting one modal VC from another :

[self.presentingViewController dismissViewControllerAnimated:YES completion:nil];
[self.presentingViewController presentViewController:modal-viewContorller2 animated:YES completion:NULL];