views:

195

answers:

1

This is a total noob question.

I have a starting view -- it's very simple: just some text and a button. When the user clicks the button, I want to go to the real "meat" of the application, which is a Navigation/Table View. How do I connect the button on the IntroViewController to a transition to the RootViewController? I don't want to make the IntroViewController a full Navigation controller and push the new view because that lets the user go back. I'm looking for some combination of code snippets and Interface Builder instructions.

+2  A: 

If you're using a UINavigationController you could just use setViewControllers:animated:

You could even fake your "back" history if you wanted to go to someplace you've never been before.

For the comments below, here's what I have in my application delegate:

- (void)applicationDidFinishLaunching:(UIApplication *)application {

        // Override point for customization after app launch
        navController = [[UINavigationController alloc] initWithRootViewController: viewController];
        [window addSubview:navController.view];
        [window makeKeyAndVisible];
}
Epsilon Prime
Because I'm a total noob, can I get some clarification? Are you suggesting one master Navigation controller (say, RootControllerView), that starts with my IntroControllerView loaded, then calls `set` instead of `push` on the transition?
James A. Rosen
You got it!Yep, you can start from the basic navigation controller template and then do exactly as you stated. Call set instead of push.
Epsilon Prime
So how do I set the `IntroViewController` as the starting view for the `RootViewController`? Is it done in Interface Builder or in code?
James A. Rosen
You can do it both ways. The default template would have you drag your desired "start" view controller to the viewController outlet on your application delegate. Then when the code reaches that first line of code in the applicationDidFinishLaunching: call above it reads the value set in IB (along with the pre-initialized variable) and uses that.
Epsilon Prime
If you wanted to just do it in code, you'd need to allocate your new view controller and then pop it on the stack. BoardSelect_ViewController *boardSelect = [[BoardSelect_ViewController alloc] initWithNibName:@"BoardSelect" bundle:nil]; [self.navigationController pushViewController:boardSelect animated:YES];(Note I have an outlet pointing to the navigationController so I can reference it here.)
Epsilon Prime