Why won't my storyboard work on the iphone?

98 views Asked by At

In the app delegate I have this written to determine which storyboard will be opened depending on the screen size,

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
UIStoryboard *storyboard = [self grabStoryboard];

// show the storyboard
self.window.rootViewController = [storyboard instantiateInitialViewController];
[self.window makeKeyAndVisible];

return YES;
}

- (UIStoryboard *)grabStoryboard {

UIStoryboard *storyboard;

// detect the height of our screen
int width = [UIScreen mainScreen].bounds.size.width;

if (width == 480) {
    storyboard = [UIStoryboard storyboardWithName:@"iphone4" bundle:nil];
    // NSLog(@"Device has a 3.5inch Display.");
} else {
    storyboard = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
    // NSLog(@"Device has a 4inch Display.");
}

return storyboard;
}

The app opens landscape on the device. This will properly choose between a 3.5 inch device and a 4 inch device in the simulators, but won't properly display in an actual 3.5 inch device. In Xcode 6 it opens the correct storyboard for the 4s or the 5, 6 ,6+ depending on the width of the screen but when tested on an actual Iphone 4s (with ios 7.1.1) the storyboard configured for 4 inch devices is displayed.

0

There are 0 answers