所以在我的最后一个问题中,我试图从 AppDelegate 实例化,但它不起作用,所以在做了更多研究之后,我一直看到 SceneDelegate 并决定试一试。令我惊讶的是,它起作用了,但并不是我想要的那样。
不要介意空格,我在自动布局方面遇到了问题,这是我将来会解决的问题。SceneDelegate.swift
我希望在使用按钮、导航栏、用户交互和正确显示的所有内容实例化 VC 时显示这个确切的图像。
现在,当我在方法中运行这段代码时SceneDelegate
willConnectTo()
......
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).
self.window = self.window ?? UIWindow()
let storyboard = UIStoryboard(name: "Main", bundle: nil)
let auth = Auth.auth()
auth.addStateDidChangeListener { (_, user) in
if let user = user {
let alreadyLoggedInViewController = storyboard.instantiateViewController(withIdentifier: Constants.StoryboardIDs.StudentEventDashboardStoryboardID) as! StudentSegmentedTableViewController
self.window!.rootViewController = alreadyLoggedInViewController
self.window!.makeKeyAndVisible()
}
}
guard let _ = (scene as? UIWindowScene) else { return }
}
我最终得到这个...
我真的很高兴看到它,因为我的代码终于可以工作了,但它没有显示带有栏按钮项目的导航栏,这有点粉碎了幸福。分段控件仍然是交互式的,并且 tableview 仍然刷新,这很棒,但我只想要我的正常 VC,以便用户可以正常使用该应用程序并查看所有其他 UI。如果有人可以帮助解决这个问题,那对我来说将是一个很大的帮助。提前致谢。