i am not using storyboard for this application so here's my SceneDelegate willConnectTo function
func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) {
let windowScene = UIWindowScene(session: session, connectionOptions: connectionOptions)
self.window = UIWindow(frame: UIScreen.main.bounds)
self.window?.backgroundColor = .white
let rootViewController = PersonsViewController()
let navigationController = UINavigationController(rootViewController: rootViewController)
navigationController.navigationBar.tintColor = .black
self.window?.rootViewController = navigationController
self.window?.makeKeyAndVisible()
self.window?.windowScene = windowScene
}
and here is the UITextView configuration function
private func configureTextView() {
textView = UITextView(frame: CGRect(x: 75, y: 120, width: view.frame.width, height: 120))
textView.font = UIFont.systemFont(ofSize: 16)
textView.textColor = .black
textView.backgroundColor = .blue
textView.delegate = self
textView.becomeFirstResponder()
textView.isUserInteractionEnabled = true
textView.keyboardType = .default
view.addSubview(textView)
}
and this is what gets printed in the console
Could not find keyboard scene delegate for interaction view <_UITextLayoutCanvasView: 0x105904be0; frame = (0 0; 375 120); userInteractionEnabled = NO; layer = <CALayer: 0x282ed8ee0>>.
2022-02-07 08:33:15.481898+0200 Project[40078:7478637] [Assert] Could not find window to attach loupe view.
I made sure that the delegate methods get called
The following code works:
func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) {
// Use this method to optionally configure and attach the UIWindow `window` to the provided UIWindowScene `scene`.
// If using a storyboard, the `window` property will automatically be initialized and attached to the scene.
// This delegate does not imply the connecting scene or session are new (see `application:configurationForConnectingSceneSession` instead).
guard let scene = (scene as? UIWindowScene) else { return }
self.window = UIWindow(windowScene: scene)
self.window?.backgroundColor = .white
let rootViewController = ViewController()
let navigationController = UINavigationController(rootViewController: rootViewController)
navigationController.navigationBar.tintColor = .black
self.window?.rootViewController = navigationController
self.window?.makeKeyAndVisible()
}