获取键盘的高度
2015-07-22 14:21
190 查看
- (void)viewDidLoad { [super viewDidLoad]; //增加监听,当键盘出现或改变时收出消息 [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWillShow:) name:UIKeyboardWillShowNotification object:nil];//注意获取键盘的高度的监听方法,应写在控制器里,若自定义的cell中,有textfield,在自定义的cell中写入监听的话,点击键盘时,第一次点击时高度获取的为0 ,之后再点击才获取到键盘的高度(至于为什么现在还没想清楚) //增加监听,当键退出时收出消息 [[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 { }
相关文章推荐
- error LNK2019: unresolved external symbol "__declspec(dllimport) const CReadUserInfo::`vftable'" (__
- Android滚轮选择器实现
- tiptop中Table显示图片的方法
- Hadoop Mapreduce Kpi 用Hadoop提取KPI统计指标
- 转-squid介绍及其简单配置
- Android滚轮选择器实现 分类: Android 2015-07-22 14:21 128人阅读 评论(0) 收藏
- android打包上架之预防反编译(花指令)
- [LeetCode]Binary Tree Level Order Traversal
- codevs1055
- OpenCV 实践程序17——用C++实现ip camera的视频播放
- Android实现动态体温计
- Android 无线调试
- Diesel-engined devices toronto and additionally equipment enjoy a great fanatic sticking with
- I/O特性
- TCP/IP详解学习笔记(8)-DNS域名系统
- Find Minimum in Rotated Sorted Array II
- kvm(六)客户机vm的主机快照
- Singleton模式,类模板,多线程
- hihoCoder 字符消除
- 百度API获取位置范围内的周边服务