uiscenedelegate

Set rootViewController programmatically not working, picking initial view controller from storyboard only in Xcode 11

二次信任 提交于 2021-01-29 16:20:35
问题 Trying to change the root view controller programmatically, initially in storyboard as initial view controller is checked. Every time same viewController is opened which is set up as initialViewController in storyboard. Please guide. Sharing below what code tried so far: let isLoggedIn = UserDefaults.standard.bool(forKey: kIsLoggedIn) if isLoggedIn{ //Welcome Screen for Touch ID let storyboard = UIStoryboard(name: "Main", bundle: nil) // let rootVC = storyboard.instantiateViewController

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

Setting Up CoreData with SceneDelegate - unknown identifier 'window' error - iOS 13 onwards

微笑、不失礼 提交于 2020-05-29 11:57:57
问题 I was trying to use the official apple documentation for Core Data. Found here. I also ran into a question which was related to my issue, right here on stack. I ran into an issue where, it kept saying that 'window' is not available in the context of AppDelegate. This is the very basic step as per the official documentation. func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { if let rootVC = window?

AppDelegate and SceneDelegate when supporting iOS 12 and 13

橙三吉。 提交于 2020-04-27 04:40:14
问题 I need to support iOS 12 and iOS 13. Should I be duplicating code between AppDelegate and SceneDelegate ? For example: func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) { guard let windowScene = (scene as? UIWindowScene) else { return } let window = UIWindow(windowScene: windowScene) window.rootViewController = HomeViewController() window.makeKeyAndVisible() self.window = window } and func application(_ application:

AppDelegate and SceneDelegate when supporting iOS 12 and 13

一世执手 提交于 2020-04-27 04:37:52
问题 I need to support iOS 12 and iOS 13. Should I be duplicating code between AppDelegate and SceneDelegate ? For example: func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) { guard let windowScene = (scene as? UIWindowScene) else { return } let window = UIWindow(windowScene: windowScene) window.rootViewController = HomeViewController() window.makeKeyAndVisible() self.window = window } and func application(_ application:

How to make Onboarding work with Scene Delegate in iOS13?

丶灬走出姿态 提交于 2020-04-18 12:33:33
问题 I am trying to set up my onboarding screen in the SceneDelegate. When I run the code below, it compiles, but just goes to a black screen. They're many great onboarding tutorials for AppDelegate, but very few for the new SceneDelegate with iOS13. I took this tutorial and tried to apply it to SceneDelegate, but I can't get it to work: https://www.youtube.com/watch?v=y6t1woVd6RQ&t=537s This is my scene delegate code. var window: UIWindow? func scene(_ scene: UIScene, willConnectTo session:

How to make Onboarding work with Scene Delegate in iOS13?

為{幸葍}努か 提交于 2020-04-18 12:32:30
问题 I am trying to set up my onboarding screen in the SceneDelegate. When I run the code below, it compiles, but just goes to a black screen. They're many great onboarding tutorials for AppDelegate, but very few for the new SceneDelegate with iOS13. I took this tutorial and tried to apply it to SceneDelegate, but I can't get it to work: https://www.youtube.com/watch?v=y6t1woVd6RQ&t=537s This is my scene delegate code. var window: UIWindow? func scene(_ scene: UIScene, willConnectTo session:

Reload/refresh a scene after receive remote notification swiftUI

余生长醉 提交于 2020-02-06 08:44:40
问题 I have this problem. I'm receiving a notification from CloudKit using application:didReceiveRemoteNotification in AppDelegate. I'm able to receive the recordId, fetch it, and save it successfully. The problem is, the scene doesn't refresh. final class UserData: ObservableObject { @Published var items: [Item] = [] func saveFetchedItem(recordId: CKRecord.ID, reason: CKQueryNotification.Reason) { fetchAndSaveRemoteDataFromCloudKit(recordId: recordId, reason: reason, userData: self) } } in

`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: