I would like to enable the done button on the navbar (in a modal view) when the user writes at least a char in a uitextfield. I tried:
Swift 2.2
You can assign custom method "checkTextField()" to "myTextField" UITextField as:
myTextField.addTarget(self, action: #selector(self.checkTextField(_:)), forControlEvents: .EditingChanged);
and toggle the done button inside the method as:
func checkTextField(sender: UITextField) {
doneButton.enabled = !sender.hasText();
}
No need of any delegate.