UIKeyboardWillShowNotification 监听键盘高度变化
2015-02-02 16:38
357 查看
UIKeyboardWillShowNotification 通知来获得当键盘改变时,该键盘的高度和位置。
然后调整自己相应的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位置
}
然后调整自己相应的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位置
}
相关文章推荐
- UIKeyboardWillShowNotification 监听键盘高度变化
- UIKeyboardWillShowNotification 真机中,在键盘为中文键盘时,会调用多次
- iOS8 UIKeyboardWillShowNotification 键盘遮挡问题
- 通过 UIKeyboardWillShowNotification 捕获软键盘事件 一个搜索效果的实现
- iPad 通知 UIKeyboardWillShowNotification 不会在keyBoard处在Undock状态下接到通知
- IOS8 keyboardWillShow 在UIKeyboardWillShowNotification 调用两次 问题解决
- iOS开发之监听键盘高度的变化
- 监听键盘高度变化,以及键盘自定义
- 实时获取键盘高度 CGSize keyboardSize = [[[notification userInfo] objectForKey:UIKeyboardFrameEndUserInfoKey] CGRectValue].size;
- UIKeyboardWillShowNotification
- 监听键盘高度变化
- iOS开发之监听键盘高度的变化
- iOS开发之监听键盘高度的变化 分类: ios技术 2015-04-21 12:04 233人阅读 评论(0) 收藏
- ios开发 监听键盘frame变化事件获取键盘高度( ios8&ios7 横竖屏旋转时需要注意的问题)
- iOS开发之监听键盘高度的变化
- UIKeyboardWillShowNotification & UIKeyboardDidShowNotification report wrong keyboard height
- 通过 UIKeyboardWillShowNotification 捕获软键盘事件 一个搜索效果的实现
- 视图随键盘的弹出整体上移UIKeyboardWillChangeFrameNotification
- iOS开发之监听键盘高度的变化
- Xamarin: Moving the view on Keyboard show 弹出键盘时移动view高度