Search code examples
iosnibios-universal-app

iOS Universal apps, and nibs / xibs


I have a universal app in development.

The app uses NIBs, and I have, for example,

ExcitingViewController.xib
ExcitingViewController~iPad.xib

On the iPhone or iPad simulator, the appropriate variant is picked up automagically (i.e. the one with the ~iPad suffix is selected on the iPad without any code change).

However, on a real iPad the iPhone variant is always used.

I've seen mention of selecting the appropriate NIB programatically, but as this is handled automagically on the simulator, I don't see why it couldn't be on a real deice.

if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone)
{
    excitingViewController = [[ExcitingViewController alloc] initWithNibName:@"ExcitingViewController" bundle:nil];
}
else
{
    excitingViewController = [[ExcitingViewController alloc] initWithNibName:@"ExcitingViewController~iPad" bundle:nil];
}

Any tips on getting the ~iPad variants selected automatically on a real device?

(btw, the simulators are normally utterly dependable in exhibiting the correct behaviour, so it's annoying to find these differences / bugs).


Solution

  • OK, the answer does seem to be that you need to handle this programmatically (as shown in the question), which seems like a missed opportunity by Apple, but maybe there's more to it.