NotificationCenter.default.addObserver(forName: UIScreen.didConnectNotification, object: nil, queue: nil) { (notification) in // Get the new screen information. let newScreen = notification.object as! UIScreen let screenDimensions = newScreen.bounds
// Configure a window for the screen. let newWindow = UIWindow(frame: screenDimensions) newWindow.screen = newScreen // Install a custom root view controller in the window. self.configureAuxilliaryInterface(with: newWindow)
// You must show the window explicitly. newWindow.isHidden = false // Save a reference to the window in a local array. self.additionalWindows.append(newWindow)}
funcapplication(_ application: UIApplication, configurationForConnecting connectingSceneSession: UISceneSession, options: UIScene.ConnectionOptions) -> UISceneConfiguration { // Called when a new scene session is being created. // Use this method to select a configuration to create the new scene with.
print(UIApplication.shared.connectedScenes) let scene = UIWindowScene(session: connectingSceneSession, connectionOptions: options)
// Configure a window for the screen. self.newWindow = UIWindow(frame: CGRect(x: 0, y: 0, width: 1000, height: 500)) // self.newWindow.backgroundColor = UIColor.yellow // Install a custom root view controller in the window.
let viewController = UIStoryboard(name: "Main", bundle: nil).instantiateViewController(identifier: "other") as! OtherViewController self.newWindow.rootViewController = viewController self.newWindow.windowScene = scene
// You must show the window explicitly. self.newWindow.isHidden = false