[英]SwiftUI Picker does not respect frame size on device
我的 Picker 視圖僅在設備上超出了框架大小,而在模擬器中工作正常。 此視圖不是 Form 或 List 的一部分,只是在 VStack 中
var body: some View {
HStack {
Text(title)
.foregroundColor(.gray)
Spacer()
if isEditing {
Picker(selection: $value) {
Section {
Text("None").tag("None")
}
Section {
ForEach(Countries.all, id: \.self) { i in
Text(i).tag(i)
}
}
} label: {}
.frame(height: DocumentPage.rowHeight) // <-- This is ignored
} else {
// View when not editing
}
}
.frame(height: DocumentPage.rowHeight) // <-- And this is ignored
}
在模擬器上與在設備上
在 Picker() 上使用.layoutPriority(1)並在 Text( )上使用 .fixedSize() 有幫助。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.