我在選項卡視圖中使用文本欄位,但是當鍵盤顯示時。鍵盤上有空格。
在此處輸入影像描述
var body: some View {
TabView {
TestView()
}
}
var body: some View {
VStack {
ScrollView(.vertical, showsIndicators: false) {
ForEach(0..<100) { data in
Text("\(data)")
}
}
Spacer()
HStack {
Image(systemName: "paperplane")
TextField("test field", text: $test)
.textFieldStyle(RoundedBorderTextFieldStyle())
}
}
.padding()
.ignoresSafeArea(.keyboard, edges: .bottom)
}
如果我在沒有 Tab 視圖的情況下使用,鍵盤作業得很好。
在此處輸入影像描述
我進行了一些搜索并放了.ignoresSafeArea(.keyboard, edges: .bottom),我不知道為什么它仍然不起作用。
uj5u.com熱心網友回復:
修飾符應應用在正確的位置:
HStack {
Image(systemName: "paperplane")
TextField("test field", text: $test)
.textFieldStyle(RoundedBorderTextFieldStyle())
}
.ignoresSafeArea(.keyboard, edges: .bottom) // << here !!
使用 Xcode 13.4 / iOS 15.5 測驗
轉載請註明出處,本文鏈接:https://www.uj5u.com/qukuanlian/481293.html
標籤:IOS 迅捷 键盘 ios15 swiftui-tabview