Outer and inner displays transition

When the app moves between the outer and inner displays, does SwiftUI preserve view identity end to end: @State, scroll position, @FocusState, an active text field with the keyboard up, presented sheets and popovers? Is anything recreated, and does scenePhase change during the transition?

Answered by Technology Evangelist in 906436022

Hello! This question is answered in the Summary of the iPhone Duo Group Lab https://developer.apple.com/forums/thread/847644

How should apps preserve state — text input, scroll position, video playback, camera sessions — during hinge angle transitions? For example, when a LazyVGrid's column count changes because the device folds, does SwiftUI preserve scroll position automatically, or should you use scrollPosition(id:)?

The system generally preserves text input and scroll position automatically since hinge angle changes are represented as size-class and trait updates, not a scene disconnect or app termination. This applies even to cases like a LazyVGrid column-count change triggered by opening or closing the device — apps typically don't need to manually manage scroll position with scrollPosition(id⚓ ) for this transition. For more info, see Prepare your app for iPhone Duo.

Accepted Answer

Hello! This question is answered in the Summary of the iPhone Duo Group Lab https://developer.apple.com/forums/thread/847644

How should apps preserve state — text input, scroll position, video playback, camera sessions — during hinge angle transitions? For example, when a LazyVGrid's column count changes because the device folds, does SwiftUI preserve scroll position automatically, or should you use scrollPosition(id:)?

The system generally preserves text input and scroll position automatically since hinge angle changes are represented as size-class and trait updates, not a scene disconnect or app termination. This applies even to cases like a LazyVGrid column-count change triggered by opening or closing the device — apps typically don't need to manually manage scroll position with scrollPosition(id⚓ ) for this transition. For more info, see Prepare your app for iPhone Duo.

Outer and inner displays transition
 
 
Q