HurkNburkS
HurkNburkS

Reputation: 5510

How to load different nib for iPad?

I would like to load a different .xib for my root view when my app is running on an iPad. I have tried to do as you can see from the code below, however what happens is the thread goes into the correct if statement so it identifies that it's an iPad however when the view loads it loads the iPhone version of the view.

Here is my code, I am trying to decide in the app delegate which nib to load for the rootView:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{

    //Add status bar
    [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent];
    [[UIApplication sharedApplication] setStatusBarHidden:NO withAnimation:UIStatusBarAnimationFade];


    if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {
        self.window.rootViewController = [[RootViewController alloc] initWithNibName:@"RootViewControlleriPad" bundle:nil];
    } else {
        self.window.rootViewController = [[RootViewController alloc] initWithNibName:@"RootViewController" bundle:nil];
    }


    self.window.rootViewController = self.navigationController; //Adds RootViewController to the NavigationController interface
    self.navigationController.navigationBar.titleTextAttributes =  @{NSForegroundColorAttributeName : [UIColor whiteColor]}; // navigation titles
    self.navigationController.navigationBar.tintColor = [UIColor whiteColor]; // navigation buttons

Upvotes: 0

Views: 194

Answers (1)

Michael Dautermann
Michael Dautermann

Reputation: 89509

You need to rework this line:

self.window.rootViewController = self.navigationController; //Adds RootViewController to the NavigationController interface

which is what's goofing up your results.

Upvotes: 2

Related Questions