不同的故事板为不同的屏幕

时间:2016-09-05 21:17:23

标签: ios storyboard

Apple批准这个解决方案吗?我在appDelegate中调用不同的故事板以获得不同的分辨率。我狂野不使用autolayout。 http://pinkstone.co.uk/how-to-load-uistoryboards-depending-on-screen-height-in-ios/

- (UIStoryboard *)grabStoryboard {

// determine screen size
int screenHeight = [UIScreen mainScreen].bounds.size.height;
UIStoryboard *storyboard;

switch (screenHeight) {

        // iPhone 4s
    case 480:
        storyboard = [UIStoryboard storyboardWithName:@"Main-4s" bundle:nil];
        break;

        // iPhone 5s
        case 568:
        storyboard = [UIStoryboard storyboardWithName:@"Main-5s" bundle:nil];
        break;

        // iPhone 6
        case 667:
        storyboard = [UIStoryboard storyboardWithName:@"Main-6" bundle:nil];
        break;

        // iPhone 6 Plus
        case 736:
        storyboard = [UIStoryboard storyboardWithName:@"Main-6-Plus" bundle:nil];
        break;

    default:
        // it's an iPad
        storyboard = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
        break;
}

return storyboard;

}

0 个答案:

没有答案