mirror of
https://github.com/zydeco/minivmac4ios.git
synced 2024-11-22 03:30:59 +00:00
33 lines
1.1 KiB
Swift
33 lines
1.1 KiB
Swift
//
|
|
// KeyboardSceneDelegate.swift
|
|
// Mini vMac
|
|
//
|
|
// Created by Jesús A. Álvarez on 2024-02-10.
|
|
// Copyright © 2024 namedfork. All rights reserved.
|
|
//
|
|
|
|
import UIKit
|
|
|
|
class KeyboardSceneDelegate: UIResponder, UIWindowSceneDelegate {
|
|
var window: UIWindow?
|
|
|
|
func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) {
|
|
guard let windowScene = scene as? UIWindowScene else {
|
|
fatalError("Expected scene of type UIWindowScene but got an unexpected type")
|
|
}
|
|
guard let mainViewController = AppDelegate.sharedInstance().window.rootViewController as? ViewController else {
|
|
fatalError("No main view controller")
|
|
}
|
|
|
|
let size = mainViewController.keyboardViewController.preferredContentSize
|
|
windowScene.sizeRestrictions?.minimumSize = size
|
|
windowScene.sizeRestrictions?.maximumSize = size
|
|
window = UIWindow(windowScene: windowScene)
|
|
|
|
if let window {
|
|
window.rootViewController = mainViewController.keyboardViewController
|
|
window.makeKeyAndVisible()
|
|
}
|
|
}
|
|
}
|