Could not find a storyboard named 'Main' in bundle

前端 未结 24 1691
无人共我
无人共我 2020-12-01 00:26

I\'m getting a strange error: \'Could not find a storyboard named \'Main\' in bundle NSBundle\' when trying to run my app on a real iOS device.

I have

24条回答
  •  夕颜
    夕颜 (楼主)
    2020-12-01 01:05

    If still you have black screen, then try adding below code in your scene delegate

    willConnectTo

        guard let windowScene = (scene as? UIWindowScene) else { return }
        window = UIWindow(frame: windowScene.coordinateSpace.bounds)
        window?.windowScene = windowScene
        let navController = UINavigationController()
        let mainstoryboard:UIStoryboard = UIStoryboard(name: "Your storyboard name", bundle: nil)
        let initialController = mainstoryboard.instantiateViewController(withIdentifier: "your initial controller Identifier") as! initialController
        navController.addChild(initialController)
        window?.rootViewController = navController
        window?.makeKeyAndVisible()
    

提交回复
热议问题