How NOT to dismiss keyboard when touch outside

Hello,


I have the feeling I'm about to get laughed at, but I've lost so much time over this already that I don't care anymore...


I am trying to PREVENT resignFirstResponder to be called when user taps outside UITextfields (and of course, outside my custom inputView).


I remember from my early indie dev years, as I was struggling through the initial "Hello World" sample code, that this was the default behavior.

That sample code walked us through how to actually dismiss the keyboard BY tapping outside of it...


But I am now trying to PREVENT this.

I want users to dismiss the keyboard ONLY by tapping on the DONE button in my accessoryView.

Any ideas ?

Normally these will work on the view controller directly but they are false by default:

    override var canBecomeFirstResponder: Bool {
        return false
    }
    override var canResignFirstResponder: Bool {
        return false
    }


But it sounds like you have a delegate implementation for the UITextField protocol UITextFieldDelegate that is calling resignFirstResponder() on a UTtextField reference when editiing is done.


Look for an implementation of one of these protocol methods if implemented.

    @available(iOS 2.0, *)
    optional public func textFieldDidEndEditing(_ textField: UITextField) / 
    @available(iOS 10.0, *)
    optional public func textFieldDidEndEditing(_ textField: UITextField, reason: UITextFieldDidEndEditingReason) // if implemented, called in place of textFieldDidEndEditing:
How NOT to dismiss keyboard when touch outside
 
 
Q