Note that there are some explanatory texts on larger screens.

plurals
  1. POLoading different xib for iPhone 5 fails
    text
    copied!<p>I'm trying to make my app detect if the user is on a iPhone 5 screen or not.</p> <p>I'm successfully using the following method in other views.</p> <p>Via a button I call the Xib / view to be loaded</p> <pre><code>- (IBAction)DemoTapeTwo:(id)sender { if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone) { DemoTapeTwoViewController *Second = [[DemoTapeTwoViewController alloc] initWithNibName:nil bundle:nil]; [self presentViewController:Second animated:YES completion:NULL]; } else { DemoTapeTwoViewController *Second = [[DemoTapeTwoViewController alloc] initWithNibName:@"DemoTapeTwoViewController_iPad" bundle:nil]; [self presentViewController:Second animated:YES completion:NULL]; } </code></pre> <p>I have two xib's,</p> <p>iPhone 5 one : XViewController_568.xib</p> <p>iPhone 4 one : XViewController.xib</p> <pre><code>- (id)initWithNibName:(NSString *)nibName bundle:(NSBundle *)nibBundle { if ([[ UIScreen mainScreen ] bounds ].size.height == 568 ) { nibName = [NSString stringWithFormat:@"%@_568", nibName]; } if (self = [super initWithNibName:nibName bundle:nibBundle]) { } return self; } </code></pre> <p>This ^ goes in the .m file</p> <p>It should detect if the screen is a iPhone 5 or iPhone 4 screen and adjust the Xib to it.</p> <p>However, Xcode errors out : </p> <p>Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Could not load NIB in bundle: 'NSBundle /Users/SamGuichelaar/Library/Application Support/iPhone Simulator/6.1/Applications/321B4512-7BD3-46D8-A944-F12029448326/Parkway Drive Gestures.app (loaded)' with name '(null)_568'' First throw call stack:</p> <p>So, something goes wrong making it not find the original name of the iPhone 4 Xib.</p> <p>Can anyone help me?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload