I made custom UIWindow for overlay, and the UserInteractionEnabled is false. It seems working good, touch action in default window's rootViewController. But when I present modal, some official iOS SDK's UI component (ex. CNContactPickerViewController), it does not working for touch action.
- There is default window and default rootViewController.
- I made new UIWindow for overlay.
- The Overlay window's "userInteractionEnabled" is false, and their subviews's "userInteractionEnabled" is false as well.
- makeKeyAndVisible for default window and overlayWindow
- The default viewController is working good touch action.
- I presented CNContactPickerViewController as modal, but the picker view controller is not working for touch action.
- I tested another official UI components as well, but action is not working. ex) PHPhotoPickerViewController, UIActivityViewController, UIDocumentPickerViewController, and so on...
var window: UIWindow?
var overlayWindow: UIWindow?
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 windowScene = (scene as? UIWindowScene) else { return }
overlayWindow = UIWindow(windowScene: windowScene)
overlayWindow?.clipsToBounds = true
overlayWindow?.backgroundColor = UIColor.clear
overlayWindow?.isUserInteractionEnabled = false
let mainStoryboard = UIStoryboard(name: "Main", bundle: nil)
let overlayViewController = mainStoryboard.instantiateViewController(withIdentifier: "OverlayViewController") as! OverlayViewController
overlayWindow?.rootViewController = overlayViewController
overlayWindow?.windowLevel = UIWindow.Level(UIWindow.Level.statusBar.rawValue + 10)
let screenSize = UIScreen.main.bounds.size
overlayWindow?.frame = CGRect(x: 0, y: 0, width: screenSize.width, height: screenSize.height)
overlayWindow?.makeKeyAndVisible()
self.window?.makeKeyAndVisible()
}
do you have any good advice?
