Search code examples
iphonexcodeios5uinavigationcontrollernavigation

Cannot find Xcode 4 new project template for navigation controller based app. Any alternative?


I am working on iOS 5. I am not able to find the navigation based application template formerly found in Xcode.

So what can I use instead?


Solution

  • You need to use Master-Detail Application template. Choose Device Family from dropdown list as iPhone. After creating a project your appDelegate will contain UINavigationController instance.

    @interface AppDelegate : UIResponder <UIApplicationDelegate>
    
    @property (strong, nonatomic) UIWindow *window;
    @property (strong, nonatomic) UINavigationController *navigationController;
    
    @end
    

    and

    @implementation AppDelegate
    
    @synthesize window = _window;
    @synthesize navigationController = _navigationController;
    
    - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
    {
        self.window = [[[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]] autorelease];
        // Override point for customization after application launch.
    
        MasterViewController *masterViewController = [[[MasterViewController alloc] initWithNibName:@"MasterViewController" bundle:nil] autorelease];
        self.navigationController = [[[UINavigationController alloc] initWithRootViewController:masterViewController] autorelease];
        self.window.rootViewController = self.navigationController;
        [self.window makeKeyAndVisible];
        return YES;
    }