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:
But shouldChangeCharactersInRange won't be called when user press clear button of text field control. And your button should also be disabled when text field is empty.
A IBAction can be connected with Editing Changed event of text field control. And it will be called when users type or press clear button.
- (IBAction) editDidChanged: (id) sender {
if (((UITextField*)sender).text.length > 0) {
[yourButton setEnabled:YES];
} else {
[yourButton setEnabled:NO];
}
}