iPhone 6是一个不同的故事板?

1 storyboard ios iphone-6

当我们有了iPhone 4 and 5,我们检查了屏幕尺寸,并为每个iPhone制作了2个故事板.

 //iPhone 4
    if (height == 480)
    {
        storyboard = [UIStoryboard storyboardWithName:@"StoryboardiPhone" bundle:nil];
         NSLog(@"Device has a 3.5inch Display.");
    }
    //iPhone 5
    else  if (height == 568)
    {
        storyboard = [UIStoryboard storyboardWithName:@"StoryboardiPhone5" bundle:nil];
          NSLog(@"Device has a 4inch Display.");
    }
    //iPads
    else
    {
        storyboard = [UIStoryboard storyboardWithName:@"Storyboard" bundle:nil];
        NSLog(@"Device has a iPad Display  ");

    }
Run Code Online (Sandbox Code Playgroud)

现在还有2个iPhone,问题是,为所有iPhone和iPad 制作5个 是正确的storyboards吗?在我看来这是一件错误的事情,但是我找不到一种方法来安排一个设备中的视图,并使其适合所有其他设备 - 并确保它总是很好用.

现在什么是正确的方法?

bpo*_*lat 5

最好的方法是使用AutoLayout,但如果由于某种原因仍然需要针对不同的屏幕尺寸使用不同的故事板,则以下是一个有效的代码.

if ([UIDevice currentDevice].userInterfaceIdiom == UIUserInterfaceIdiomPad) {
    //iPad
    storyBoard = [UIStoryboard storyboardWithName:@"MainStoryboard_iPad" bundle:nil];
}else{
    if ([UIDevice currentDevice].userInterfaceIdiom == UIUserInterfaceIdiomPhone){
        // The iOS device = iPhone or iPod Touch
        CGSize iOSDeviceScreenSize = [[UIScreen mainScreen] bounds].size;
        if (iOSDeviceScreenSize.height == 480){
            // iPhone 3/4x
            storyBoard = [UIStoryboard storyboardWithName:@"MainStoryboard_iPhone3_4X" bundle:nil];
        }else if (iOSDeviceScreenSize.height == 568){
            // iPhone 5 - 5s - 4 inch
            storyBoard = [UIStoryboard storyboardWithName:@"MainStoryboard_iPhone5_5S" bundle:nil];
        }else if (iOSDeviceScreenSize.height == 667){
            // iPhone 6 4.7 inch
            storyBoard = [UIStoryboard storyboardWithName:@"MainStoryboard_iPhone6" bundle:nil];
        } else if (iOSDeviceScreenSize.height == 736){
            // iPhone 6 Plus 5.5 inch
            storyBoard = [UIStoryboard storyboardWithName:@"MainStoryboard_iPhone6Plus" bundle:nil];
        }

    }
}
Run Code Online (Sandbox Code Playgroud)

要启用原生iPhone 6和iPhone 6以及屏幕分辨率,请添加启动图像

在此输入图像描述