Get onAppear behaviour from list in ScrollView in SwiftUI

前端 未结 2 1505
甜味超标
甜味超标 2021-02-20 18:06

When creating a List view onAppear triggers for elements in that list the way you would expect: As soon as you scroll to that element the onAppea

2条回答
  •  余生分开走
    2021-02-20 18:15

    As per SwiftUI 2.0 (XCode 12 beta 1) this is finally natively solved: In a LazyHStack (or any other grid or stack with the Lazy prefix) elements will only initialise (and therefore trigger onAppear) when they appear on screen.

提交回复
热议问题