Detect UITextField Lost Focus

Viewed 18607

i searched a lot googling and heree, but nothing useful.

I have two textfields and i don't able to recognize which one lost the focus.
I tried all options, but nothing.

Here the textFieldDidEndEditing:

- (void) textFieldDidEndEditing:(UITextField *)textField {  
  NSLog(@"%@", [textField state]);
  NSLog(@"%d", [textField isSelected]);
  NSLog(@"%d", [textField isFirstResponder]);
  NSLog(@"%d", [textField isHighlighted]);
  NSLog(@"%d", [textField isTouchInside]);

  if ( ![textField isFirstResponder] || ![textField isSelected] ) {
  //if ( [textField state] != UIControlStateSelected) {
    NSLog(@"not selected!");
    [...]
    // remove view / etc...
  }
}

All NSLog returns 0! Why?!?

How can i detect lost focus? This method has called every time that i press a keyboard button, non only at the end!
Is there any alternatives?

EDIT:
I don't want to switch from texts but i want to detect lost focus when i click anyways on screen. (the keyboard will dismiss or not and the caret is not present on textfield)!

thanks.

4 Answers
Related