0

I want to add navigation controller to view controller which is the rootviewcontroller of the window. Two xib files main window.xib and view controller.xib files.

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
// Override point for customization after application launch.

self.window.rootViewController = self.viewController;

[self.window makeKeyAndVisible];

return YES;
}

tried this

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
 {
// Override point for customization after application launch.

self.window.rootViewController = self.viewController;

self.navController = [[UINavigationController alloc] initWithRootViewController:self.viewController];

 [self.window addSubview:self.navController.view];

[self.window makeKeyAndVisible];
return YES;
}

but not working i think as there are two xib files involved.

1

1 Answer 1

0

You are not setting the root view controller correctly. You are close though. Here is the right code.

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
 {
// Override point for customization after application launch.

self.navController = [[UINavigationController alloc] initWithRootViewController:self.viewController];


self.window.rootViewController = self.navController;

[self.window makeKeyAndVisible];
return YES;
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.