을
theTextField.delegate = self;
내가 UIActionSheet가 UITextFieldDelegate 프로토콜을 빨아 들었으며, 알림 센터는 동일한 기능을 수행 할 수있는 나는이 문제를 가지고 있었다 사용자가 화면의 다른 곳을 탭했을 때 키보드를 닫을 때. 제스처 인식기를 사용하여 탭을 찾고 탭이 감지되면 텍스트 필드에서 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의 위임은 이미 self로 설정되어 있지만 차이는 없습니다. – icecreamhead
UITextfield 대리자를 변경하는 항목을 찾아서 (자동으로 설정하는 항목 제외) 주석 처리하십시오. 그런 다음 작동하는지 확인하십시오. 나는 당신의 상황에서 NSLog가 어렵 기 때문에 파일에 쓰는 것을 사용할 것입니다. –