Reputation: 4271
i need to get this infomation, how to detect if we dismiss keyboard programmatically and dismiss by tap keyboard in uitextview? both of them called
-(BOOL)textViewShouldEndEditing:(UITextView *)textView
but how to detect it difference? can somebody give me some clue?
Upvotes: 0
Views: 449
Reputation: 50707
You can create a notification observer and listen for certain events:
// 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];
Upvotes: 1