0

I found that when I use this method, click the done button on the keyboard, the keyboard will not close automatically:

struct Test: View {
    
    @State private var currentText: String = ""
    
    var body: some View {
        
        // this method: init(_ titleKey: LocalizedStringKey, text: Binding<String>, axis: Axis)
        TextField("say something...", text: $currentText, axis: .vertical)
            .font(.subheadline)
            .lineLimit(2, reservesSpace: true)
            .padding()
            .submitLabel(.done)
            .border(.red)
    }
}

But when I switch to this method, click done, the keyboard will automatically close, is this a bug?

// init(_ titleKey: LocalizedStringKey, text: Binding<String>)
TextField("say something...", text: $currentText)
            .font(.subheadline)
            .lineLimit(2, reservesSpace: true)
            .padding()
            .submitLabel(.done)
            .border(.red)

I want to be able to use the method with the 'axis' feature, and click 'done' without wrapping automatically, how can this be achieved?

24K Lin
  • 1
  • 1

0 Answers0