swift app启动黑屏

新建swift  APP后, 设置rootviewcontroller  为其他Controller,如果 勾选的是main.storyboard 运行app ,删除后main.storyboard会有黑屏问题。

1.检查info.plist 文件

首先我们去到info.plist,删掉如下图箭头所示

2.删除SceneDelegate.swift  文件

3.删除APPdelegate.swift 中 与Scene相关的代码

4.在APPdelegate.swift里面添加window属性

 
 
  1. class AppDelegate: UIResponder, UIApplicationDelegate {

  2. var window: UIWindow?

  3. /**

  4. *入口区,调用区

  5. */

  6. func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {

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

  8. window?.rootViewController = vc

  9. window?.makeKeyAndVisible()

  10. return true

  11. }

  12. }

猜你喜欢

转载自blog.csdn.net/ios_xumin/article/details/123990036