在 appdelegate 中跳过登录屏幕在 swift 中不起作用

skipping login screen in appdelegate not working in swift

我正在尝试跳过 appdelegate 中的登录屏幕,我正在使用世界知名的方法将下一个视图控制器分配给 rootviewcontroller 但不知何故它无法用于测试目的我没有设置任何条件并且直接执行此代码但不会反映在应用程序中。

my loginViewController is embedded in navigationController

let storyboard = UIStoryboard(name: "Main", bundle: nil)
let homepage = storyboard.instantiateViewController(withIdentifier: "mainTabBarController") as! mainTabBarController
self.window?.rootViewController = homepage
self.window?.makeKeyAndVisible()

我已经经历了很多这样的答案,但他们建议使用相同的方法。

"comment for extra info on the question".

如果您使用的是 Xcode 11 及以上

  1. 删除SceneDelegate.swift
  2. AppDelegate
  3. 中删除 UISceneSession Lifecycle 方法
  4. AppDelegate中添加var window: UIWindow?class
  5. 打开Info.plist并删除Application Scene Manifest
  6. didFinishLaunchingWithOptions 方法中添加以下行
self.window = UIWindow(frame: UIScreen.main.bounds)     
self.window?.rootViewController = //...
self.window?.makeKeyAndVisible()