Post

Replies

Boosts

Views

Activity

Reply to LazyVStack in ScrollView flitters on insertion in iOS 17
Find a solution for iOS 17+. Reduce Data Struct into a one-dimensional Array. /** ✅ Make sure LazyVStack is always visible. */ ScrollView { LazyVStack { ForEach(data) { item in switch item.viewStyle { // dynamic config view by data case 1: DynamicHeightView1() case 2: DynamicHeightView2() default: DynamicHeightView() } } } } /** ❌ The contents inside a LazyVStack may disappear from view when the user is scrolling or when the keyboard changes the focus state. */ ScrollView { ForEach(data) { section in LazyVStack { ForEach(section) { row in DynamicHeightView() } } } } // ❌ or ScrollView { View() LazyVStack { ForEach(section) { row in DynamicHeightView() } } LazyVStack { ForEach(section) { row in DynamicHeightView() } } View() }
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Dec ’23
Reply to LazyVStack in ScrollView flitters on insertion in iOS 17
Find a solution for iOS 17+. Reduce Data Struct into a one-dimensional Array. /** ✅ Make sure LazyVStack is always visible. */ ScrollView { LazyVStack { ForEach(data) { item in switch item.viewStyle { // dynamic config view by data case 1: DynamicHeightView1() case 2: DynamicHeightView2() default: DynamicHeightView() } } } } /** ❌ The contents inside a LazyVStack may disappear from view when the user is scrolling or when the keyboard changes the focus state. */ ScrollView { ForEach(data) { section in LazyVStack { ForEach(section) { row in DynamicHeightView() } } } } // ❌ or ScrollView { View() LazyVStack { ForEach(section) { row in DynamicHeightView() } } LazyVStack { ForEach(section) { row in DynamicHeightView() } } View() }
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Dec ’23