动态获取键盘的高度

1 给键盘添加监听事件

[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(myKeyBoardAction:) name:UIKeyboardDidShowNotification object:nil];

2 实现监听方法

1 - (void)myKeyBoardAction:(NSNotification *)notif {
2     NSDictionary *dic = [notif userInfo];
3     NSValue *value = [dic objectForKey:UIKeyboardFrameBeginUserInfoKey];
4     CGSize size = [value CGRectValue].size;
5     NSLog(@"-------%@",NSStringFromCGSize(size));
6 }
原文地址:https://www.cnblogs.com/lovestarfish/p/4993288.html