Posts

Post not yet marked as solved
1 Replies
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!
Post not yet marked as solved
5 Replies
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!
Post not yet marked as solved
7 Replies
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!
Post not yet marked as solved
7 Replies
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!
Post not yet marked as solved
7 Replies
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) }
Post not yet marked as solved
4 Replies
I was seeing pretty much the same thing but it had to with the mechanism I was using to update my UI. The extra call(s) made by iPadOS to capture screens in light and dark mode should usually be transparent to the user. Just be careful with what you're actually doing when the userInterfaceStyle changes. Improper tasks can lead to flickering of light and dark mode. I was suffering from that problem because I was using notification pattern to update multiple viewControllers. Doing something more direct corrected the problem my specific issue.Good luck!
Post not yet marked as solved
4 Replies
I'm seeing pretty much the same thing ... Did you ever solve the issue of the unwanted flickering between light and dark mode?Thanks!
Post marked as solved
20 Replies
I'm running Mojave 10.14.6 and was experiencing the crash. I have converted two UITextViews in two apps from Storyboard to programatically generated and am not seeing any crashes.