2

我有一个在新 Xcode 11 中不起作用的路由器,它作为 appDelegate 工作。现在我需要转换到另一个 SCENE,我尝试了在这里找到的所有问题,但它仍然不起作用。以下是无法转换到预期下一个场景的代码:

class Router {

static let shared = Router()

private init() {}

private let rootViewController: UIViewController = ViewController()

func root(_ window: inout UIWindow?) {
    // need to set frame or Scene
    window?.makeKeyAndVisible()
    window?.rootViewController = rootViewController
}

}

    func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) {
    guard let windowScene = (scene as? UIWindowScene) else { return }
    window = UIWindow(windowScene: windowScene)
    Router.shared.root(&window)
}
4

0 回答 0