0
votes

I am using the JSQMessageViewController, i need to endEditing of the keyboard when the user taps return button on the keyboard but instead it adds "\n" in the textField. I had gone through the JSQMessageViewController.m, JSQMessagesInputToolbar.m but did'nt got any textfield function textfieldShouldReturn.

1
possible due to the returnKeyType of textfield?user3349433
@user3349433 i tried thats too. i have added the delegate method textfieldShouldReturn and in it i added the self.view.endEditing(true) but i was'nt working at all. i changed the keyboard type to UIKeyboardDone but it was working same.Ronit

1 Answers

0
votes

i got the solution

override func textView(_ textView: UITextView, shouldChangeTextIn range: NSRange, replacementText text: String) -> Bool {
    if text == "\n" {
      self.view.endEditing(true)
    }
    return true
  }