简体   繁体   中英

Multiple storyboards for different iPhone sizes

I have the below code set up in appDel.m in didFinishLaunching. I currently have 2 storyboards iPhone 5 and iPhone 6. The issues is the code I am using is not selecting the iPhone 5 storyboard, it always defaults to the iPhone 6.

UIStoryboard *storyBd;
CGSize result = [[UIScreen mainScreen]bounds].size;
CGFloat scale = [UIScreen mainScreen].scale;
result = CGSizeMake(result.width, result.height * scale);

NSLog(@"The Result height is %f",result.height);

if (result.height == 1136) {
    storyBd = [UIStoryboard storyboardWithName:@"i5Story" bundle:nil];
    UIViewController *initView = [storyBd instantiateInitialViewController];
    [self.window setRootViewController:initView];
}else if (result.height == 1334){
     storyBd = [UIStoryboard storyboardWithName:@"i6Story" bundle:nil];
    UIViewController *initView = [storyBd instantiateInitialViewController];
    [self.window setRootViewController:initView];
}

Thats because the height isn't 1136 it is 568 . You don't look for the retina height (1136), just the normal "1x" pixel size.

Also you really shouldn't do this, rather use auto layout and make one storyboard.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM