n.evermind
n.evermind

Reputation: 12004

Showing two UIViewController at the same time

I have two UIViewControllers which I sometimes need to show at the same time. Imagine ViewController A only has one button and is otherwise transparent. Once I touch the button I would like ViewController B (which is green) to fade in and do other custom animations, but ViewController A (and the button) needs to be still shown on top of B. Once the fade/animation etc. are over, only ViewController B (green) is visible.

My questions:

1) What is the best setup? UINavigationController with hidden NavBar doesn't make much sense. TabBarController with hidden TabBar strikes me as equally odd as I don't need the TabBar. 2) I'm a bit confused about views and windows. The window is init'ed in my AppDelegate and then I would add a RootViewController:

self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
self.viewController = [[ViewController alloc] init];
self.window.rootViewController = self.viewController;
[self.window makeKeyAndVisible];

If I want to have two ViewController's views on top of each other as described above, would I need to add the view of ViewController B (the green one) to ViewController A (the one with the button)? Do I need to swap the rootViewControllers?

Ideally, I don't want to take care of all the ViewDidAppear's of VC A and B, so I guess UINavigationController/TabBar would not be a bad idea after all, if I could customise the transitions between Controllers.


Edit:

I really need two different VCs as I would do more complex things than just display a button, like having a scrollview in VC A and another scrollview in VC B. I don't want to have two scrollviews (or tableViews etc.) in one VC as this gets messy.

Upvotes: 0

Views: 646

Answers (1)

sosborn
sosborn

Reputation: 14694

The best way is to have only one view controller. View A will just sit on top of B until you fade it out.

Upvotes: 1

Related Questions