1

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)

1 Answer 1

1

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
            }
        }
    }

enter image description here

Sign up to request clarification or add additional context in comments.

2 Comments

did not work for me
Can you elaborate? What exactly did you do? This should work

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.