无法在iOS 13 [Xcode 11 GM种子2]上更改Main.storyboard的名称 [英] Cannot change Main.storyboard's name on iOS 13 [Xcode 11 GM seed 2]

查看:153
本文介绍了无法在iOS 13 [Xcode 11 GM种子2]上更改Main.storyboard的名称的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在具有Xcode 11 GM种子2的iOS 13模拟器上,Main.storyboard的名称更改(Info.plist也更改)后,应用程序崩溃.将选项Main Interface设置为空会导致相同的问题. iOS 13系统始终尝试找到Main.storyboard,但失败并显示崩溃消息:

On iOS 13 simulator with Xcode 11 GM seed 2, the app crashes after Main.storyboard's name changed (Info.plist changed also). Setting option Main Interface to empty cause the same problem. The iOS 13 system always try to find the Main.storyboard, and failed with crashing message:

*** reason: 'Could not find a storyboard named 'Main' in bundle

在iOS 12和更低版本上一切正常.看起来像是iOS 13中的错误.

Everything is fine on iOS 12 and earlier versions. It looks like a bug in iOS 13.

有人遇到同样的问题吗?还有解决方案吗?

Does anyone meet same problem? And any solutions?

推荐答案

使用iOS 13的Swift 5

应用程序下的 info.plist 文件中还需要进行其他更改 场景清单组.

One more changes require in info.plist file under Application Scene Manifest group.

应用场景清单中更改名称.

其他:
如果要在iOS13上创建没有情节提要的根窗口,则需要从 Info.plist 中删除Main storyboard file base nameStoryboard Name项,然后创建该窗口以编程方式在SceneDelegate中:

Additional:
If you want to create the root window without a storyboard on iOS13, you need removing the Main storyboard file base name and Storyboard Name item from Info.plist, and then create the window programmatically in SceneDelegate:

class AppDelegate: UIResponder, UIApplicationDelegate {
    func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
        // Override point for customization after application launch.
        if #available(iOS 13.0, *) {
            //Do nothing here
        } else {
            window = UIWindow(frame: UIScreen.main.bounds)
            window?.makeKeyAndVisible()
        }

        return true
    }
}

class SceneDelegate: UIResponder, UIWindowSceneDelegate {

    var window: UIWindow?

    @available(iOS 13.0, *)
    func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) {
        // Use this method to optionally configure and attach the UIWindow `window` to the provided UIWindowScene `scene`.
        // If using a storyboard, the `window` property will automatically be initialized and attached to the scene.
        // This delegate does not imply the connecting scene or session are new (see `application:configurationForConnectingSceneSession` instead).
        guard let windowScene = (scene as? UIWindowScene) else { return }
        window = UIWindow(windowScene: windowScene)
        // continue to create view controllers for window
    }

    //......
}

这篇关于无法在iOS 13 [Xcode 11 GM种子2]上更改Main.storyboard的名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆