Я искал много googling и heree, но ничего полезного.
У меня есть два текстовых поля, и я не могу распознать, какой из них потерял фокус.
Я пробовал все варианты, но ничего.
Здесь 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...
}
}
Все NSLog возвращает 0! Почему?!?
Как я могу обнаружить потерянный фокус? Этот метод вызывал каждый раз, когда я нажимаю кнопку клавиатуры, не только в конце!
Есть ли альтернативы?
ИЗМЕНИТЬ:
Я не хочу переключаться с текстов, но хочу обнаружить потерянный фокус, когда я нажимаю на экран в любом случае. (клавиатура отклоняется или нет, а каретка отсутствует в текстовом поле)!
спасибо.