Question

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

Was it helpful?

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.

OTHER TIPS

You should not need the Resources-iPad/ prefix on the name of the iPad nib. iOS knows how to find resources in your bundle. The folder hierarchy you see in Xcode is simply for organizing files and for the developer's benefit.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top