iOS监听键盘弹出,获取键盘的高度
2015-12-29 22:19
471 查看
<pre name="code" class="objc">
- (void)viewDidLoad { [super viewDidLoad]; //增加监听,当键盘出现或改变时收出消息 [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWillShow:) name:UIKeyboardWillShowNotification object:nil]; //增加监听,当键退出时收出消息 [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWillHide:) name:UIKeyboardWillHideNotification object:nil]; } //当键盘出现或改变时调用 - (void)keyboardWillShow:(NSNotification *)aNotification { //获取键盘的高度 NSDictionary *userInfo = [aNotification userInfo]; NSValue *aValue = [userInfo objectForKey:UIKeyboardFrameEndUserInfoKey]; CGRect keyboardRect = [aValue CGRectValue]; int height = keyboardRect.size.height; } //当键退出时调用 - (void)keyboardWillHide:(NSNotification *)aNotification { }
相关文章推荐
- IOS 项目简介
- iOS清除缓存
- ios开发中的小技巧
- runtime ---- iOS
- ios 开发中宏定义的三种方式及优先级
- 广点通 (iOS完整版)
- iOS --- CoreGraphics中三种绘图context切换方式的区别
- 蓝懿ios练习整理笔记
- 2015.12.29 iOS SimpleCalculator简单计算器
- iOS的性能优化
- iOS中解决各种手势冲突问题
- AudioSource声音播放的静态方法
- iOS 中KVC、KVO、NSNotification、delegate 总结及区别
- iOS7中的ViewController切换(一.present与dismiss方式)
- ios 并行开发
- iOS 搜索框
- iOS开发融云即时通讯集成详细步骤
- runtime模型与字典互转
- About iOS总结
- 百度告警-Nagios接入