WillEnterForeground

"How does the app handle fold state during background transitions and foreground launch on Apple Duo?

  1. If the device folds while the app is being moved to the background, does the app save the fold state in the scene state data?

  2. When the app returns to the foreground, should the fold state be restored to accurately recreate the UI?

  3. If a user opens the app via a notification action while the device is already folded, how should the initial view layout be determined?

  4. Should SceneDelegate handle fold state transitions during scene lifecycle events (willResignActive, didBecomeActive)?"

Answered by Frameworks Engineer in 906734022

Hi there!

You generally should not think of responding to the fold at the scene-level of your app.

I'd recommend starting off with "Strike a pose with adaptive layouts on iPhone Duo":

https://developer.apple.com/videos/play/tech-talks/111463/

Instead of asking "what is the hinge state when transitioning to the foreground", you should think much more granular than that.

From that video, consider using built-in containers that have consistent and automatic responses the fold. Or for custom split or overlay views, use an ArrangementView that will also automatically respond to the fold.

For elements that are manually positioned and need "displacement" like that video mentions, that's where the Reserved Regions API would come in.

So, to answer some of your questions directly:

If the device folds while the app is being moved to the background, does the app save the fold state in the scene state data?

When the app returns to the foreground, should the fold state be restored to accurately recreate the UI?

Reserved Region and hinge data will be up to date when your app's scene transitions to the foreground.

If a user opens the app via a notification action while the device is already folded, how should the initial view layout be determined?

If you are using a built-in container view controller or an ArrangementView, this will be done for you. If you are using Reserved Regions, you'll query these in the layout of the specific view you want to adapt to the fold, and observation tracking will re-trigger layout when the regions change.

Should SceneDelegate handle fold state transitions during scene lifecycle events (willResignActive, didBecomeActive)?"

As mentioned above, this is sort of the wrong question. You should think about adapting to the hinge through either built-in containers, ArrangementViews, or reserved regions, all of which are layout based and not tied to a scene lifecycle event.

Hi there!

You generally should not think of responding to the fold at the scene-level of your app.

I'd recommend starting off with "Strike a pose with adaptive layouts on iPhone Duo":

https://developer.apple.com/videos/play/tech-talks/111463/

Instead of asking "what is the hinge state when transitioning to the foreground", you should think much more granular than that.

From that video, consider using built-in containers that have consistent and automatic responses the fold. Or for custom split or overlay views, use an ArrangementView that will also automatically respond to the fold.

For elements that are manually positioned and need "displacement" like that video mentions, that's where the Reserved Regions API would come in.

So, to answer some of your questions directly:

If the device folds while the app is being moved to the background, does the app save the fold state in the scene state data?

When the app returns to the foreground, should the fold state be restored to accurately recreate the UI?

Reserved Region and hinge data will be up to date when your app's scene transitions to the foreground.

If a user opens the app via a notification action while the device is already folded, how should the initial view layout be determined?

If you are using a built-in container view controller or an ArrangementView, this will be done for you. If you are using Reserved Regions, you'll query these in the layout of the specific view you want to adapt to the fold, and observation tracking will re-trigger layout when the regions change.

Should SceneDelegate handle fold state transitions during scene lifecycle events (willResignActive, didBecomeActive)?"

As mentioned above, this is sort of the wrong question. You should think about adapting to the hinge through either built-in containers, ArrangementViews, or reserved regions, all of which are layout based and not tied to a scene lifecycle event.

WillEnterForeground
 
 
Q