Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/swift/19.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios UIViewController未从AppDelegate显示_Ios_Swift_Firebase_Firebase Authentication_Appdelegate - Fatal编程技术网

Ios UIViewController未从AppDelegate显示

Ios UIViewController未从AppDelegate显示,ios,swift,firebase,firebase-authentication,appdelegate,Ios,Swift,Firebase,Firebase Authentication,Appdelegate,如果用户尚未实例化,我尝试在ViewController中显示注册/登录,但由于某些原因,ViewController不想显示自己,它显示的是一个没有任何内容的黑色页面。这是我的AppDelegate.swift文件中的内容,如果用户还没有注册(我还没有注册),它应该显示ViewController。我在VC的ViewDidLoad()中设置了一个断点,该断点没有命中。有人知道出了什么问题吗 var window: UIWindow? func application(_ applic

如果用户尚未实例化,我尝试在ViewController中显示注册/登录,但由于某些原因,ViewController不想显示自己,它显示的是一个没有任何内容的黑色页面。这是我的
AppDelegate.swift
文件中的内容,如果用户还没有注册(我还没有注册),它应该显示ViewController。我在VC的
ViewDidLoad()
中设置了一个断点,该断点没有命中。有人知道出了什么问题吗

var window: UIWindow?

    func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
        // Override point for customization after application launch.
        FirebaseApp.configure()

        if Auth.auth().currentUser == nil {
            let storyboard = UIStoryboard(name: "Main", bundle: Bundle.main)
            let authVC = storyboard.instantiateViewController(identifier: "AuthVC")
            window?.makeKeyAndVisible()
            window?.rootViewController?.present(authVC, animated: true, completion: nil)

        }
        return true
    }

如果删除了场景代理,则需要先创建窗口,然后再向其显示任何内容

window  = UIWindow(frame: UIScreen.main.bounds)
if let window = window {
window.rootViewController = UIViewController()
window.makeKeyAndVisible()
window.rootViewController?.present(authVC, animated: true, completion: nil)
}
为现场大使

 func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) {
    // Use this method to optionally configure and attach the UIWindow `window` to the provided UIWindowScene `scene`.
    // If using a storyboard, the `window` property will automatically be initialized and attached to the scene.


   // This delegate does not imply the connecting scene or session are new (see `application:configurationForConnectingSceneSession` instead).
     guard let windowScene = (scene as? UIWindowScene) else { return }

     window = UIWindow(windowScene: windowScene)
     let navigationController = UINavigationController(rootViewController: UIViewController()) // instead of UIViewController() give it your application root controller... which you want to show when you dismiss presented controller 
     window?.rootViewController = navigationController  
     window?.makeKeyAndVisible()
     window?.rootViewController?.present(authVC, animated: true, completion: nil)
    }

您的
rootViewController
可能
nil
,在if语句中设置断点。是否有场景委托类?是的,在这种情况下,您负责分配根视图控制器。这可能是一个包含
authVC
的导航控制器,也可能是
authVC
本身,具体取决于您登录后所做的操作。rootViewController确实是nilI deleted SceneDelegate,因为我读到它可能会干扰窗口。makeyeandvisible()函数viewdiload触发,但是实际的ViewController没有显示,你知道为什么吗?我添加了SceneDelegate,其didload名为?AuthVC,我想显示的VC,但它实际上没有显示VC,它只是转到我的初始VC]所以你现在使用场景代理或应用程序代理?