I am trying to present a custom view controller to external connected screen in iOS 13. I followed this tutorial:
I have following code:
/// A private method used to setup a external screen with a window
/// loaded with a ExternalScreenViewController
///
/// - parameter screen: A UIScreen object to connect the
/// ExternalScreenViewController too
private func setupExternalScreen(screen: UIScreen) {
guard externalWindow == nil,
let vc = self.storyboard?.instantiateViewControllerWithIdentifier("ExternalScreen") as? ExternalScreenViewController else {
return
}
externalWindow = UIWindow(frame: screen.bounds)
externalWindow!.rootViewController = vc
externalWindow!.screen = screen
externalWindow!.hidden = false
}
In the line externalWindow!.screen = screen
I am getting an error in the Xcode 11.4.1 console:
[Assert] Error in UIKit client: -[UIWindow setScreen:] should not be called if the client adopts UIScene lifecycle. Call -[UIWindow setWindowScene:] instead.
The custom view controller does not show up in the external display.
What should I change? I want to handle both iOS 13.x and prior devices.