[英]SwiftUI Picker animation bug after selection
When I select something from my picker, the animation / highlight stays there, and doesn't disappear.当我从我的选择器中取出 select 的东西时,animation / 高光停留在那里,并且不会消失。
Picker(selection: $selectedFrameworkIndex, label: HStack {
Image(systemName: "location.fill")
Text("Indulás innen:")
}) {
ForEach(0 ..< stations.count, id: \.self) {
if direction == stations[$0].direction {
Text(stations[$0].name)
}
}
}
@State private var selectedFrameworkIndex = 0
It looks like another iOS 14.2 defect.它看起来像另一个 iOS 14.2 缺陷。
Try the following workaround:尝试以下解决方法:
Picker(selection: $selectedFrameworkIndex, label:
HStack {
Image(systemName: "location.fill")
Text("Indulás innen:")
}) {
ForEach(0 ..< stations.count, id: \.self) {
if direction == stations[$0].direction {
Text(stations[$0].name)
}
}
}.id(selectedFrameworkIndex) // << here !!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.