Post

Replies

Boosts

Views

Activity

Issues with .scrollPosition in iOS17
I suppose that .scrollPosition doesn't work at current XCode version (Version 15.0 (15A240d) Variable scrollID just does not update in any situation. Can anyone get this problem, too? @State var scrollID: TestStruct? var data: [TestStruct] = [ TestStruct(name: "123", price: "34555"), TestStruct(name: "432", price: "543"), TestStruct(name: "423", price: "23"), TestStruct(name: "523", price: "543") ] var body: some View { VStack { ScrollView(.horizontal) { HStack { ForEach (data) { item in VStack { Text(item.name) Text(item.price) } .containerRelativeFrame(.horizontal) } } .scrollTargetLayout() } .scrollTargetBehavior(.paging) .scrollPosition(id: $scrollID) Text("test: \(scrollID?.name ?? "NONE")") } } } struct TestStruct: Identifiable, Hashable { let id: String = UUID().description let name: String let price: String }
2
1
1.3k
Oct ’23