A paged ScrollView loses its page when the window is resized on iPadOS 27:
ScrollView(.horizontal) {
HStack(spacing: 0) {
ForEach(pages) { page in
PageView(page).containerRelativeFrame(.horizontal)
}
}
.scrollTargetLayout()
}
.scrollTargetBehavior(.paging)
.scrollPosition(id: $selection)
Expected: the selected page stays edge-aligned after the resize (as TabView(.page) does).
Actual:
The content offset is preserved in points, not pages — the view rests between pages.
scrollPosition(id:) writes nil during the resize, so the selection can't be recovered from the binding.
Both .paging and .viewAligned are affected.
Repro project (broken ScrollView, TabView control, and workaround side by side, with live instrumentation):
https://github.com/katebrr/PagedScrollResizeLab
Why not TabView(.page): it has no API for scroll position/progress observation (our analytics depend on it), inter-page spacing, partial-width peeking pages, or pausing the swipe mid-gesture.
Workaround (Workaround/View+ScrollPositionResize.swift in the repo): restore the last non-nil selection via scrollTo one Task.yield() after the resize. Works, but lands a frame late and relies on undocumented behavior.
Questions:
Is this behavior intended, or a bug?
Is there a supported way to keep a paged ScrollView anchored to its page across resizes?
Is there a more robust formulation than scrollTo after Task.yield()?
Filed as FB24688033.
Topic:
UI Frameworks
SubTopic:
SwiftUI
4
1
298