I have an iOS application where I have a UITextField whose maximum character length I set using the delegate method:
- (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string
However, I now realize that I also need to enable a UIButton *myButton
that I have when the user has entered at least one character in the same UITextField. How do I implement this?
Here is my relevant code that I have at the moment in my delegate method:
- (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string {
NSUInteger newLength = [textField.text length] + [string length] - range.length;
return (newLength > 45) ? NO : YES;
}