-1

I have a signUpViewController that allows users to sign up with a username & password. I need to be able to check in real time the input that the user has added to the usernameTextField I am currently checking it's input by implementing the following delegate method:

- (void)textFieldDidEndEditing:(UITextField *)textField
{
}

However, this only checks after the user has left the textfield, I am then able to check with my server to see if the username already exist or not. This is not giving me the desired behavior I am seeking, I want users to know right away if they name they are typing is available or not (this is the what users have come to expect from other apps).

I have reviewed the UITextField documentation but can't find a delegate method that will do the work I am looking for, any ideas as to what I can do to get the desired behavior?

vzm
  • 2,440
  • 6
  • 28
  • 47

1 Answers1

0

UITextField Delegates are...

- (BOOL)textFieldShouldBeginEditing:(UITextField *)textField;        // return NO to disallow editing.
- (void)textFieldDidBeginEditing:(UITextField *)textField;           // became first responder
- (BOOL)textFieldShouldEndEditing:(UITextField *)textField;          // return YES to allow editing to stop and to resign first responder status. NO to disallow the editing session to end
- (void)textFieldDidEndEditing:(UITextField *)textField;             // may be called if forced even if shouldEndEditing returns NO (e.g. view removed from window) or endEditing:YES called

- (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string;   // return NO to not change text

- (BOOL)textFieldShouldClear:(UITextField *)textField;               // called when clear button pressed. return NO to ignore (no notifications)
- (BOOL)textFieldShouldReturn:(UITextField *)textField;              // called when 'return' key pressed. return NO to ignore.

In this case, you can use ..

 - (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string;   // return NO to not change text
Ryan
  • 4,799
  • 1
  • 29
  • 56
  • I implemented `- (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string;` and while I can see the code working in the debugger, its not allowing my text to show up as I type in the text field, any idea why? – vzm Jul 17 '14 at 00:03
  • the delegate methods do not cover the target/action capabilities of UITextField – vikingosegundo Jul 17 '14 at 00:07
  • You better read apple's class reference first. If the delegate method return YES, it will change the text of your textfield, otherwise it will not. – Ryan Jul 17 '14 at 00:24