簡體   English   中英

無法在 iOS 13 [Xcode 11 GM 種子 2] 上更改 Main.storyboard 的名稱

[英]Cannot change Main.storyboard's name on iOS 13 [Xcode 11 GM seed 2]

在 iOS 13 模擬器和 Xcode 11 GM 種子 2 上,應用程序在Main.storyboard的名稱更改后崩潰(Info.plist 也更改了)。 將選項Main Interface設置為空會導致同樣的問題。 iOS 13 系統總是試圖找到Main.storyboard ,並失敗並出現崩潰消息:

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

iOS 12 及更早版本上一切正常。 它看起來像 iOS 13 中的一個錯誤。

有沒有人遇到同樣的問題? 以及任何解決方案?

Swift 5 與 iOS 13

Application Scene Manifest組下的info.plist文件中還需要進行一項更改。

在此處輸入圖像描述

更改應用場景清單中的名稱。

額外的:
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
    }

    //......
}

更改Main.storyboard的名稱后,從Info.plist更改Main storyboard file base name 。當然,您可以從General - Deployment info - Main Interface更改它。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM