uiscene

How get current keywindow equivalent for multi window SceneDelegate Xcode 11?

心已入冬 提交于 2020-06-09 18:27:11
问题 I'm converting my iOS13 app for iPadOS to SceneDelegate (multi window). How can I get the current UIWindow from the current SceneDelegate? I know that a can access the current scene using UIView.window or UIViewController.view.window , but I have a non UI class (AppDelegate) where I need to get the window (keyWindow until iOS12) to show a snack bar on top of everything. I used to do [UIApplication sharedApplication].keyWindow but now, of course, that's wrong. 回答1: You'll want to simply

Getting currently focused UIScene when multiple connected scenes are active in foreground

拜拜、爱过 提交于 2020-05-15 03:45:10
问题 I have a problem getting the current UIScene when multiple scenes are connected. Specifically, my app (iOS 13) supports multiple windows on the iPad. When I have two windows side by side and I access the apps connected scenes (with UIApplication.shared.connectedScenes ), all of them have the activationState set to .foregroundActive . But I am actually only interacting with one of them. I found some code here on stackoverflow to retrieve the current key window (can't remember who it was that

`scene(_ scene: UIScene, continue userActivity: NSUserActivity)` doesn't get called when the app is launched after the user clicks on a universal link

谁说我不能喝 提交于 2019-12-23 02:19:57
问题 Method scene(_ scene: UIScene, continue userActivity: NSUserActivity) doesn't get called when the app is launched after the user clicks on a universal link. It works fine when already launched app opens again after the user clicks on the universal link. The sample code: func scene(_ scene: UIScene, continue userActivity: NSUserActivity) { guard userActivity.activityType == NSUserActivityTypeBrowsingWeb, let incomingURL = userActivity.webpageURL, let components = NSURLComponents(url:

`scene(_ scene: UIScene, continue userActivity: NSUserActivity)` doesn't get called when the app is launched after the user clicks on a universal link

风格不统一 提交于 2019-12-06 21:50:34
Method scene(_ scene: UIScene, continue userActivity: NSUserActivity) doesn't get called when the app is launched after the user clicks on a universal link. It works fine when already launched app opens again after the user clicks on the universal link. The sample code: func scene(_ scene: UIScene, continue userActivity: NSUserActivity) { guard userActivity.activityType == NSUserActivityTypeBrowsingWeb, let incomingURL = userActivity.webpageURL, let components = NSURLComponents(url: incomingURL, resolvingAgainstBaseURL: true), let path = components.path else { return } let params = components

How to resolve: 'keyWindow' was deprecated in iOS 13.0

只愿长相守 提交于 2019-11-29 07:59:57
I'm using Core Data with Cloud Kit, and have therefore to check the iCloud user status during application startup. In case of problems I want to issue a dialog to the user, and I do it using UIApplication.shared.keyWindow?.rootViewController?.present(...) up to now. In Xcode 11 beta 4, there is now a new deprecation message, telling me: 'keyWindow' was deprecated in iOS 13.0: Should not be used for applications that support multiple scenes as it returns a key window across all connected scenes How shall I present the dialog instead? This is my solution: let keyWindow = UIApplication.shared

How to resolve: 'keyWindow' was deprecated in iOS 13.0

跟風遠走 提交于 2019-11-26 12:26:51
问题 I\'m using Core Data with Cloud Kit, and have therefore to check the iCloud user status during application startup. In case of problems I want to issue a dialog to the user, and I do it using UIApplication.shared.keyWindow?.rootViewController?.present(...) up to now. In Xcode 11 beta 4, there is now a new deprecation message, telling me: \'keyWindow\' was deprecated in iOS 13.0: Should not be used for applications that support multiple scenes as it returns a key window across all connected