适用于不同iPhone尺寸的多个故事板

时间:2016-08-25 20:05:56

标签: ios objective-c storyboard

我在didFinishLaunching的appDel.m中设置了以下代码。 我目前有2个故事板iPhone 5和iPhone 6.问题是我使用的代码没有选择iPhone 5故事板,它总是默认为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];
}

1 个答案:

答案 0 :(得分:3)

多数民众赞成因为身高不是1136而是568。你没有寻找视网膜高度(1136),只是正常的“1x”像素大小。

另外你真的不应该这样做,而是使用自动布局并制作一个故事板。

相关问题