Post

Replies

Boosts

Views

Activity

Reply to viewcontroller lifecycle in UIWindowSceneDelegate
In my scene delegate, I instantiate the view controller which I then embed in a Navgiation controller (I need a nav bar); see lines 22, 24 and 40 below. func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) { guard let windowScene = (scene as? UIWindowScene) else { return } let rootViewController: UIViewController if let shortcutItem = connectionOptions.shortcutItem { dPrint("\(#function) \(shortcutItem)") } closeWindow = nil let persistentId = scene.session.persistentIdentifier if let activity = connectionOptions.userActivities.first ?? session.stateRestorationActivity, let identifier = getIdentifier(from: activity) { scene.title = activity.title ?? identifier if isMultiScenesSupported { closeWindow = UIBarButtonItem(barButtonSystemItem: .done, target: self, action: #selector(closeWindowAction)) closeWindow?.setAccessibilityProperties("CloseWindow") } // The identifier corresponds to the storyboard ID for a detail viewcontroller. let detailViewController = instantiateViewController(with: identifier) // Embed in a navigation controller to provide title and Done button. rootViewController = UINavigationController(rootViewController: detailViewController) detailViewController.restorable?.restore(from: activity, isStandalone: isMultiScenesSupported, persistentId: persistentId) } else { let identifier = AppMainFeatureData.calculator.storyboardIdentifier // The identifier corresponds to the storyboard ID for a detail viewcontroller. let detailViewController = instantiateViewController(with: identifier) // Embed in a navigation controller to provide title and Done button. rootViewController = UINavigationController(rootViewController: detailViewController) detailViewController.restorable?.restore(from: NSUserActivity(activityType: AppMainFeatureData.calculator.activityType), isStandalone: isMultiScenesSupported, persistentId: persistentId) } window = UIWindow(windowScene: windowScene) window?.rootViewController = rootViewController window?.makeKeyAndVisible() } public func instantiateViewController(with identifier: String) -> UIViewController { UIStoryboard(name: storyboardName, bundle: nil).instantiateViewController(withIdentifier: identifier) }
Jun ’20
Reply to viewcontroller lifecycle in UIWindowSceneDelegate
Sorry about that ...I should have also also mentioned that the lack of calls to trailing view controller life cycle methods appears to be when I create new scenes. That's why I posted that code.I have all those SceneDelegate methods you mentioned above implemented and they work fine as far scene life cycle is concerned.I need to support iOS < 13 and I typically add/remove observers in viewWillAppear()/viewWillDisappear(). I can certainly handle the removing of observers in one of the SceneDelegate methods. But I just find it strange that the view controller life cycle methods area called when the view is appearing (creating a new scence) but now when the view is dissapearing (removing a scene in Expose).Are you creating a new scene and are able to see calls to viewWillDisappear() and/or viewDidDisappear() when you disconnect the scene? By, for example, swiping up in Expose?Thanks!
Jun ’20
Reply to viewcontroller lifecycle in UIWindowSceneDelegate
Thanks for the reply. I have all that!I guess I still have one basic question: are ViewController life cycle methods viewWillDisappear() and viewDidDisappear() still supposed to be called in iOS 13 when supporting scenes and closing a scene?If that's the case it's not happening in my app and I'll dig into "why".I just wanted to make sure that is the case before chasing my tail too long.Thank!
Jun ’20
Reply to More info on restore state between split and tab hierarchies needed please
I agree that the Restore protocol appears to be something you write or perhaps already wrote. If you're using iPadOS maybe you already implemented multiple windows. Well, state restoration is a key concept in multiple windows and the required restoration is similar to what needs to be done when transitioning between different size class with side bars and tab bars. Hope this helps!
Jan ’21
Reply to UISplitViewController: Expanding and collapsing strategy unclear
The lifecycle of viewcontrollers doesn't really to do it the way you're proposing (which I actually considered). You have to write the mentioned Restore protocol or perhaps you already wrote it. If you're using iPadOS maybe you already implemented multiple windows. Well, state restoration is a key concept in multiple windows and the required restoration is similar to what needs to be done when transitioning between different size class with side bars and tab bars. Hope this helps!
Jan ’21