0

I'm looking to implement scene restoration and wanted to make sure that I have the right idea on how to approach this. Currently, my application supports multiple windows but every subsequent scene after the first doesn't have its UI set up (only shows an empty tab bar controller).

I thought that this could be one of two causes:

  1. AppDelegate needs to be called: My first scene configures the UI correctly, but stepping through the debugger for subsequent scenes shows that a class that configures the UI is not called. Perhaps this is an issue with how my project is set up.

  2. Scene restoration: But, I don't have scene restoration implemented AFAIK and think that this might be an issue. I found these resources: https://developer.apple.com/documentation/uikit/uiscenedelegate/supporting_multiple_windows_on_ipad and https://www.kairadiagne.com/2019/11/20/state-restoration-with-nsuseractivity.html and https://github.com/Ranchero-Software/NetNewsWire/blob/main/iOS/SceneDelegate.swift where there is a separate function that sets particular UI components based on NSUserActivity properties. I have a lot of different views in my application each with a lot of different components and don't think that I could set a property for every view and their respective components, unless I actually have to only add very few identifiers. Let me know if I am on the right track with that idea, looking for suggestions here.

Best case scenario would be that my issue is the 1st one and I have to figure out how to move my project around. But in the worst case scenario, want to know how I would approach adding things to NSUserActivity given that I am working with a very dynamic application.

HangarRash
  • 7,314
  • 5
  • 5
  • 32
Z X
  • 11
  • 2
  • The purpose of restoration is so that if your app is killed and later relaunched from scratch, it appears in the same state as it was when it was killed. Basically you get no help with restoration. Apple had a really great view controller-based restoration system but they threw it away when scenes were introduced. – matt Jul 12 '23 at 00:51
  • Scene restoration is only useful when you want your app to restore its state when the app is fully restarted. If your app is having issues when starting a 2nd scene while already running then scene restoration has nothing to do with your issue. So while your issue isn't related to scene restoration, you should look into it for the user's sake. The great thing about scene restoration and using NSUserActivity is that it's the same mechanism used for handoff. So once your app supports state restoration, it's next to nothing to support handoff. – HangarRash Jul 12 '23 at 00:56
  • Apple has a nice sample app that covers scene state restoration: [Restoring Your App's State](https://developer.apple.com/documentation/uikit/uiscenedelegate/restoring_your_app_s_state). The code is well commented and helpful. But again, it's not likely related to your issue. I post this as something to look into later. Though it may help you model your current app since it makes clear what is called in the App Delegate and Scene Delegate. – HangarRash Jul 12 '23 at 01:00
  • Thanks everyone! Appreciate the clarity. – Z X Jul 12 '23 at 16:31

0 Answers0