UIKeyboardWillShowNotification 监听键盘高度变化
监听 变化 键盘 高度
2023-09-14 08:57:55 时间
span >然后调整自己相应的UI元素位置即可,示例代码如下:
-(void)viewDidLoad{
[superviewDidLoad];
[[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(keyboardWillShow:) name:UIKeyboardWillShowNotification object:nil];
}
-(void)viewDidUnload{
[superviewDidUnload];
[[NSNotificationCenter defaultCenter]removeObserver:self];
}
-(void)keyboardWillShow:(NSNotification*)notification{
NSDictionary*info=[notification userInfo];
CGSize kbSize=[[info objectForKey:UIKeyboardFrameEndUserInfoKey]CGRectValue].size;
NSLog(@"keyboard changed, keyboard width = %f, height = %f",
kbSize.width,kbSize.height);
//在这里调整UI位置
}
-(void)viewDidLoad{
[superviewDidLoad];
[[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(keyboardWillShow:) name:UIKeyboardWillShowNotification object:nil];
}
-(void)viewDidUnload{
[superviewDidUnload];
[[NSNotificationCenter defaultCenter]removeObserver:self];
}
-(void)keyboardWillShow:(NSNotification*)notification{
NSDictionary*info=[notification userInfo];
CGSize kbSize=[[info objectForKey:UIKeyboardFrameEndUserInfoKey]CGRectValue].size;
NSLog(@"keyboard changed, keyboard width = %f, height = %f",
kbSize.width,kbSize.height);
//在这里调整UI位置
}
相关文章
- Qt利用QFileSystemWatcher对文件或目录监听fileChanged
- 监听自身卸载,弹出用户反馈调查
- 计算机改名引发的ORA-12541: TNS无监听程序错误
- ORACLE清理、截断监听日志文件(listener.log)
- ajax 上传文件,监听进度(progress)
- Activity中 左滑动返回监听
- MFC Windows 程序设计[九十]之监听剪切板(附源码)
- [Contract] 监听 MetaMask 网络变化, 账号切换
- 如何查看监听某个端口的进程明细
- uni-app底部导航栏tabBar监听变化以及变换样式
- Android实现监听音量的变化
- Flutter进阶第9篇:检测网络连接,监听网络变化
- react如何监听路由url变化
- e793. 监听JSpinner数据变化
- html5+监听设备加速度变化信息
- WinFrom、C# 学习记录二 监听usb设备变化、获取usb设备信息