UITextField resign first responder iOS4

dusker picture dusker · Jul 6, 2010 · Viewed 8.4k times · Source

I have a simple piece of code that works on every system except iOS4. It's about resigning first responder for a UITextField. The text field is all wired up, and here's the code for the delegate:

- (BOOL)textFieldShouldReturn:(UITextField *)textField{
    [opis resignFirstResponder];
    return YES;
}

I've tried it almost every possible way, trying to return NO as well and it doesn't work. The weirdest thing is that it DOES work on every iphone OS before 4.0 and on iPad as well (tested in simulators and on actual devices) Can anyone help?

Answer

Charter picture Charter · Jul 6, 2010

This worked with my 3GS in iOS4. Are you sure you properly set the UITextField delegate?

- (BOOL) textFieldShouldReturn:(UITextField*)textField {
[textField resignFirstResponder];
return YES;
}