Я имел эту проблему когда я отклонял клавиатуру, когда пользователь прослушивал в другом месте экрана. У меня был распознаватель жестов, который искал краны, и когда был обнаружен кран, он вызывал resignFirstResponder в текстовое поле. К сожалению, это сломает кнопку очистки.
Что я сделал фильтр кранов, чтобы убедиться, что они находятся вне поля зрения таблицы, немного усложнены, чтобы вручную вызвать нажатия кнопок:
// In: - (void)handleTap:(UITapGestureRecognizer *)sender {
// The user tapped outside a text field, drop the keyboard.
// Unfortunately this normally breaks the clear button, so we'll check that the
// tap is outside the table view (and therefore not on a clear button).
BOOL inButton = CGRectContainsPoint(self.signInButton.bounds, [sender locationInView:self.signInButton]);
BOOL inTable = CGRectContainsPoint(self.tableView.bounds, [sender locationInView:self.tableView]);
if (!inTable && !inButton) {
BOOL didEndEditing = [self.view endEditing:NO];
// But... if we were editing a field (& therefore the keyboard is showing),
// and if they tapped the sign in button, sign in. Not sure where the
// onSignIn event is getting lost. The button does highlight. But the
// call to endEditing seems to eat it.
if (didEndEditing && inButton) {
[self onSignIn:self.signInButton];
}
}
Делегат textField уже настроен на себя, но это не имеет никакого значения. – icecreamhead
Найдите все, что изменяет делегат UITextfield (кроме того, который устанавливает его на себя) и прокомментирует его. Затем посмотрите, работает ли он. Я бы использовал что-то, что пишет в файл, потому что NSLog в вашей ситуации тяжело. –