我需要获取此信息,如何检测我们是否以编程方式关闭键盘并在uitextview中通过点击键盘关闭?他们俩都叫
-(BOOL)textViewShouldEndEditing:(UITextView *)textView
但如何检测它的区别?有人能给我一些线索吗?
答案 0 :(得分:1)
您可以创建通知观察者并监听某些事件:
// 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];