swift删除SceneDelegate.swift文件报错

问题描述:

删除文件后。报错:There is no scene delegate set. A scene delegate class must be specified to use a main storyboard file.


解决办法:

1. 需要在info.plist 

删除 : UIApllicationSupportMultipleScenes 这个整条

2. 将AppDelegate.m 中的 UISceneSession lifecycle注释掉或者删掉

3、在 didFinishLaunchingWithOptions

删除UISceneSession Lifecycle 的两个方法,然后在didFinishLaunchingWithOptions内创建自己的window和rootViewController

写法:

1.定义 成员属性:

  var window:UIWindow?

2. 在didFinishLaunchingWithOptions里面写上

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

  self.window?.backgroundColor = UIColor.white

  self.window?.rootViewController = UINavigationController.init(rootViewController: ViewController())

   self.window?.makeKeyAndVisible()



完成 

你可能感兴趣的:(swift删除SceneDelegate.swift文件报错)