views:

100

answers:

3

I have a program where we are using a navigation controller and need the app to launch to one of two different views. Basically if certain info has previously been entered then we need the app to launch to view A, but if the info has never been entered then we need it to launch to view B. I am having difficulty getting this to work and am wondering what ways if any I could implement this. I am certain it needs to be done in the app delegate but I am not sure how. Thanks in advance!

A: 

From your question, it sounds as though your UINavigationController is defined inside a XIB along with your root view controller. In that case, you will need to load the appropriate view from within application:didFinishLaunchingWithOptions: of your App Delegate. From there, you can set the first view controller for the UINavigationController using setViewControllers:animated:.

Justin
A: 

I have met this issue and solved it.

In you navigation controller build a container view.

Then depending on your conditions you decided what view to put in the container. You might have built these two views beforehand. Then, you can add the view into the container view. I think the "Elements" sample has an example of the container view.

John Smith
+1  A: 

Implement the following method in your app delegate.

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{    
    [window makeKeyAndVisible];
    if(condition) {
        [window addSubview:[mainViewControllerA view]];
    } else {
        [window addSubview:[mainViewControllerB view]];
    }
}

There you can choose which view to load depending on your condition.

V1ru8
Problem is that it is only one view controller with many different views
Chris
How do you manage these views inside the UIViewController? You could make a property for every view you have and then you could access the views with mainViewController.viewA, mainViewController.viewB etc.
V1ru8