Swift 4.2无法在AppDelegate中以编程方式更改情节提要

时间:2019-07-13 21:16:07

标签: ios swift xcode

从Swift 3更新项目后,我花了几天时间尝试解决此问题

我的应用使用每种屏幕尺寸的记分板,我将带有以下代码的Storybord加载到AppDelegate中:

let screenHeight = UIScreen.main.bounds.size.height;
let storyboard : UIStoryboard?


        switch (screenHeight) {
        // iPhone 4s
        case 480:
            storyboard = UIStoryboard(name: "Main-Small", bundle: Bundle.main)
            break;

        // iPhone 5s
        case 568:
            storyboard = UIStoryboard(name: "Main-Five", bundle: Bundle.main)
            break;

        // iPhone 6
        case 667:
            storyboard = UIStoryboard(name: "Main", bundle: Bundle.main)
            break;

        // iPhone 6 Plus
        case 736:
            storyboard = UIStoryboard(name: "Main-Plus", bundle: Bundle.main)
            break;

        // iPhone X
        case 812:


            storyboard = UIStoryboard(name: "MainX", bundle: Bundle.main)
            break;

        // ipAd pro
        case 1366:
            storyboard = UIStoryboard(name: "Main-Small", bundle: Bundle.main)
            break;

        default:
            // it's an iPad
            storyboard = UIStoryboard(name: "Main-Small", bundle: Bundle.main)



            break;
        }


        let viewController = storyboard!.instantiateInitialViewController()


        self.window = UIWindow(frame: UIScreen.main.bounds)

        self.window?.rootViewController = viewController

        self.window?.makeKeyAndVisible()

一切都很好

我已经做过的事情

将主界面设置为空(Info.plist)

但是它变成了黑屏

希望有人可以帮助我解决这个问题

最好的问候

0 个答案:

没有答案