美文网首页
iOS 键盘显示或消失的监听,获取键盘高度

iOS 键盘显示或消失的监听,获取键盘高度

作者: 番薯大佬 | 来源:发表于2018-06-04 17:14 被阅读20次

键盘即将显示的通知

- (void)showKeyboard  
{  
  [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWillShow:) name:UIKeyboardWillShowNotification object:nil];  
}  

键盘即将消失的通知

-  (void)hiddenKeyboard  
{  
  [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWillHidden:) name:UIKeyboardWillHideNotification object:nil];  
}  

键盘即将显示

- (void)keyboardWillShow:(NSNotification *)notification  
{   
  NSDictionary *kbInfo=[notification userInfo];  
  CGSize kbSize=[[kbInfo objectForKey:UIKeyboardFrameEndUserInfoKey] CGRectValue].size;  
  CGFloat kbHeight = kbSize.height;// 键盘高度  
}  

键盘即将消失

- (void)keyboardWillHidden:(NSNotification *)notification  
{  

}

相关文章

网友评论

      本文标题:iOS 键盘显示或消失的监听,获取键盘高度

      本文链接:https://www.haomeiwen.com/subject/wxuysftx.html