[英]SwiftUI Keyboard Toolbar not Showing
I have a TextField for commenting but it cannot be dismissed due to the tool bar not showing on the keyboard.我有一个用于评论的 TextField,但由于工具栏未显示在键盘上,因此无法将其关闭。 Previously there was a tool bar with a done
button but it is not showing anymore, not sure what happened to it.以前有一个带有done
按钮的工具栏,但它不再显示了,不知道发生了什么。
The TextField is in a VStack/SrollView placed at the very bottom of the screen (similar to iMessage) TextField 位于屏幕底部的 VStack/SrollView 中(类似于 iMessage)
Is there a reason it has disappeared?有没有它消失的原因? is it a device setting that might have changed?它是可能已更改的设备设置吗?
TextField("comment...", text: $textToPost)
.keyboardType(.alphabet)
.padding(.leading, 20)
.lineLimit(0)
.focused($focusField, equals: .comment)
Is that what you're looking for?那是你要找的吗?
@State private var commentText = ""
@FocusState private var commentTextFieldFocus
TextField("Comment...", text: $commentText)
.keyboardType(.alphabet)
.padding(.leading, 20)
.lineLimit(0)
.focused($commentTextFieldFocus)
.toolbar {
ToolbarItemGroup(placement: .keyboard) {
Button("Done") {
commentTextFieldFocus = false
}
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.