I have a TextField for commenting but it cannot be dismissed due to the tool bar not showing on the keyboard. Previously there was a tool bar with a done
button but it is not showing anymore, not sure what happened to it.
The TextField is in a VStack/SrollView placed at the very bottom of the screen (similar to 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
}
}
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.