views:

183

answers:

2

Fundamentally, what I want to do is within, for example, ViewControllerA display ViewControllerB and ViewControllerC. How would I do that?

Thanks in advance.

+1  A: 

You don't display view controllers, you display views. Having said that, you can do something like this:

UIViewController *a = ...;
UIViewController *b = ...;
[a.view addSubview:b.view];

Now, having said that, you shouldn't do it. Tons of stuff does not behave properly, because there are tons of undocumented interactions between UIView, UIWindow, and UIViewController. There is nothing in the documentation that says it won't work, but random things stop behaving properly (viewWillAppear: on the interior view's VC doesn't get called, etc).

If you need this functionality, you should file a bug with Apple.

Louis Gerbarg
Here is the thing. I have one event that needs to trigger two screens of distinct information. How is this usually handled?
jp chance
Define 2 screens? I assume you mean a split screen with 2 views worth of information. Generally you would do it using a single view controller. Yeah, it sucks. You can implement your own controller classes and have the view controller do event routing if you want to be more generic, but it is a lot of work. In order to support this generically in a project I am doing I had to completely re-implement UIViewController, UINavigationController, UITableViewController as well as a custom UIWindow subclass to deal with the event routing.
Louis Gerbarg
A: 

The default template for a navigation view controller should do what you want assuming you want two different screens (not two different sections on the same screen). Whenever you want to change the view from the current one to another, just tell the navigation controller to push it on the stack:

[self.navigationController pushViewController:viewBoards animated:YES];

The default navigation view controller gives you a root view controller with a navigation view controller in it. It also gives you one view controller called MainWindow. Just add as many copies of MainWindow as you need to get your functionality.

Epsilon Prime
I think (correct me if I am wrong) jp wants two viewcontrollers that are not taking the entire screen to be displayed simultaneously.
Louis Gerbarg
It's not clear to me after his comment to your answer, he just may be overlooking the simple solution.
Epsilon Prime
This is what I need. Thank you.
jp chance