0

この情報を取得する必要があります。プログラムでキーボードを閉じるかどうかを検出し、uitextview でキーボードをタップして閉じる方法を教えてください。二人とも呼んだ

-(BOOL)textViewShouldEndEditing:(UITextView *)textView

しかし、その違いをどのように検出するのですか?誰かが私に手がかりを与えることができますか?

4

1 に答える 1

1

通知オブザーバーを作成して、特定のイベントをリッスンできます。

UIWindow クラス

// Each notification includes a nil object and a userInfo dictionary containing the
// begining and ending keyboard frame in screen coordinates. Use the various UIView and
// UIWindow convertRect facilities to get the frame in the desired coordinate system.
// Animation key/value pairs are only available for the "will" family of notification.
UIKIT_EXTERN NSString *const UIKeyboardWillShowNotification;
UIKIT_EXTERN NSString *const UIKeyboardDidShowNotification; 
UIKIT_EXTERN NSString *const UIKeyboardWillHideNotification; 
UIKIT_EXTERN NSString *const UIKeyboardDidHideNotification;

[[NSNotificationCenter defaultCenter] addObserver:self
                                         selector:@(keyboardDidDisappear)
                                             name:UIKeyboardDidHideNotification
                                           object:nil];
于 2012-06-04T04:16:19.733 に答える