Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>What you currently have is a subclass of a UINavigationController. That would be what you want to do if you wanted to add custom functionality to UINavigationController (like doing a different animation between views). Since it sounds like you want to make a navigation based application, you actually just want to use the plain UINavigationController class. Here is what you what you have to do to get a UINavigationController set up with the content that you want. (I am doing this in Code because I hate having to set up UINavigationController's in IB).</p> <p>In your applicationDidFinishLaunching, you want to add this bit of code.</p> <pre><code>// (SomethingApplicationDelegate.m) - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { // Assume that 'window' is your main window, and 'viewController' is the property // that is automatically created when you do a new view controller application. // // Also, assume that 'ContentViewController' is the name of the class that display // the table view. This will most likely be a subclass of UITableViewController ContentViewController *content = [[ContentViewController alloc] init]; UINavigationController *nvc = [[UINavigationController alloc] initWithRootViewController:content]; [viewController.view addSubview:nvc.view]; // This is the boilerplate code that is generated when you make a new project self.window.rootViewController = self.viewController; [self.window makeKeyAndVisible]; return YES; } </code></pre> <p>This will create a UINavigationController and set up your table view as the content of that. When you want to do the nice animation to a new view, you do this</p> <pre><code>// This will be inside your ContentViewController // Assume that 'NewViewController' is the class of the view controller you want // to display NewViewController *viewController = [[NewViewController alloc] init]; [self.navigationController pushViewController:viewController]; [viewController release] </code></pre> <p>This will automatically do the animation to slide to the next view controller, along with making the nice back button to bring you back to your ContentViewController</p> <p>EDIT: To make the navigation controller show up as a modal view controller, this is what you do. Instead of using the above code in the application delegate, you do this.</p> <pre><code>-(IBAction)buttonPushed:(id)sender { // Assume this method is in a UIViewController subclass. // // The next two lines are copied from above in the Application Delegate, the same assumptions // apply about ContentViewController ContentViewController *content = [[ContentViewController alloc] init]; UINavigationController *nvc = [[UINavigationController alloc] initWithRootViewController:content]; // This is the magic code [self presentModalViewController:nvc]; } </code></pre> <p>Then, when you are done with the navigation controller, and want it to go away, you do this:</p> <pre><code>// Assume we are in some method in ContentViewController, or a similar view controller that is showing content [self.navigationController dismissModalViewController]; </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload