Search code examples
iphoneuitextviewiphone-softkeyboard

How is a done button added to a keyboard


I have a keyboard which edits text in a UITextView and tapping the return key doenst dismiss the keyboard, it only moves down to the next line.

How can I add a done button and make that dismiss the keyboard?


Solution

  • Implement the

    textView:shouldChangeTextInRange
    

    method to look for "\n" then call

    resignFirstResponder on the textView if it is found.

    Reference