美文网首页
swift删除SceneDelegate.swift文件报错

swift删除SceneDelegate.swift文件报错

作者: Ahri阿狸 | 来源:发表于2021-04-26 14:18 被阅读0次

问题描述:

删除文件后。报错: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文件报错

      本文链接:https://www.haomeiwen.com/subject/fuherltx.html