Search code examples
iphoneobjective-ciosipaduniversal-binary

iOS Universal App - Access different Nibs for iPad and iPhone


I am writing my first universal app, I have converted my nibs so that there are iPad and iPhone versions.

The iPad version is in the Resources-iPad folder and called 'InfoViewController-iPad.xib'. The iPhone version in the main folder and called 'InfoViewController.xib'

I have the following action to show the relevant xib

-(void) touchesBegan: (NSSet *) touches withEvent: (UIEvent *) event {
    if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
    {
         infoViewController = [[InfoViewController alloc] initWithNibName:@"Resources-iPad/InfoViewController-iPad" bundle:nil];
    }
    else
    {
        infoViewController = [[InfoViewController alloc] initWithNibName:@"InfoViewController" bundle:nil];
    }

    infoViewController.delegate = self;
    infoViewController.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;

    [self presentModalViewController:infoViewController animated:YES];

    [infoViewController release];

}

When this runs on the iPhone it works fine, but it crashes when run on the iPad. Any help would really be appreciared


Solution

  • You do not need to put the folder name in the nib name for the iPad version, it will be found as long as it has a different name than the iPhone version.

    If removing the folder from the initWithNibName doesn't work for you, please edit your question and post the results of the backtrace from the console.