I am using Xcode 11 (beta3) and building an app for iOS 13. In my project I created the delegate methods for UIWindowSceneDelegate
declaring it in Info.plist.
Now I'm able to create multiple windows (and UIScene).
How can I access the rootViewController now I've not anymore a single window? I need it to get some reference to objects and bounds it holds.
In my AppDelegate window is nil
, and in my ViewController (child view controller) instance I tried using self.view.window.rootViewController
but I found out that viewDidLoad()
is too soon (I think) and the window is still nil, works in viewDidAppear()
, but I don't need to make this process every time the view controller appears.
What's the best practice with this new way to handle application scenes?
Here is my AppDelegate:
func application(_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? = nil) -> Bool {
return true
}
func application(_ application: UIApplication,
configurationForConnecting connectingSceneSession: UISceneSession,
options: UIScene.ConnectionOptions) -> UISceneConfiguration {
return UISceneConfiguration(name: "Default Configuration", sessionRole: connectingSceneSession.role)
}
My SceneDelegate:
func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) {
// yes it's empty, I'm using storyboard
}
windowScene
has value only on current scene? – Resonate