在我的SwiftUI应用程序中,我有一个带有嵌套ScrollView的列表,在我的iPhone升级到iOS 16后,主列表的刷新有奇怪的行为。似乎每个ScrollView都有自己的刷新。问题在于我已经在主列表上应用了.refreshable修改器,而不是在嵌套列表上应用。在iOS 16之前不存在这个问题。那么,这是一个错误还是我们可以以某种方式修复它?以下是代码和短视频:
List {
VStack(alignment: .leading) {
Text("Line 1")
.font(.title)
ScrollView(.horizontal, showsIndicators: false) {
LazyHStack(spacing: 20) {
Text("Item 1")
Text("Item 2")
Text("Item 3")
Text("Item 4")
Text("Item 5")
Text("Item 6")
Text("Item 7")
Text("Item 8")
Text("Item 9")
Text("Item 10")
}
.frame(height: 180)
}
}
.listRowSeparator(.hidden)
VStack(alignment: .leading) {
Text("Line 2")
.font(.title)
ScrollView(.horizontal, showsIndicators: false) {
LazyHStack(spacing: 20) {
Text("Item 1")
Text("Item 2")
Text("Item 3")
Text("Item 4")
Text("Item 5")
Text("Item 6")
Text("Item 7")
Text("Item 8")
Text("Item 9")
Text("Item 10")
}
.frame(height: 180)
}
}
.listRowSeparator(.hidden)
}
.listStyle(.plain)
.refreshable {
print("refresh!")
}