`
吃饱了就饿
  • 浏览: 66861 次
  • 性别: Icon_minigender_2
  • 来自: 北京
社区版块
存档分类
最新评论

IOS键盘监听

    博客分类:
  • IOS
阅读更多

   键盘消失

 [[NSNotificationCenterdefaultCenteraddObserver:selfselector:@selector(keyboardWasHidden:) name:UIKeyboardDidHideNotificationobject:nil];

   键盘出现

 [[NSNotificationCenterdefaultCenteraddObserver:selfselector:@selector(keyboardWasShow:) name:UIKeyboardDidShowNotification object:nil];

所有key值

UIKIT_EXTERNNSString *const UIKeyboardWillShowNotification;

UIKIT_EXTERNNSString *const UIKeyboardDidShowNotification; 

UIKIT_EXTERNNSString *const UIKeyboardWillHideNotification; 

UIKIT_EXTERNNSString *const UIKeyboardDidHideNotification;

触发方法

- (void)keyboardWillShow:(NSNotification *)notification 

{  

    CGPoint beginCentre = [[[notification userInfo] valueForKey:UIKeyboardCenterBeginUserInfoKey] CGPointValue]; 

    CGPoint endCentre = [[[notification userInfo] valueForKey:UIKeyboardCenterEndUserInfoKey] CGPointValue]; 

    CGRect keyboardBounds = [[[notification userInfo] valueForKey:UIKeyboardBoundsUserInfoKey] CGRectValue]; 

    CGRect keyboardFrames = [[[notification userInfo] valueForKey:UIKeyboardFrameEndUserInfoKey] CGRectValue]; 

    UIViewAnimationCurve animationCurve = [[[notification userInfo] valueForKey:UIKeyboardAnimationCurveUserInfoKey] intValue]; 

    NSTimeInterval animationDuration = [[[notification userInfo] valueForKey:UIKeyboardAnimationDurationUserInfoKey] doubleValue]; 

**若有警告可将key值写为@""中

0
5
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics