iOS相应键盘高度变化,相应控件随之变化的代码段
来源:互联网 发布:老公是唇膏男 知乎 编辑:程序博客网 时间:2024/05/21 11:22
//注册通知
[[NSNotificationCenterdefaultCenter] addObserver:selfselector:@selector(keyboardWillShow:)name:UIKeyboardWillShowNotificationobject:nil];
[[NSNotificationCenterdefaultCenter] addObserver:selfselector:@selector(keyboardWillHide:)name:UIKeyboardWillHideNotificationobject:nil];
//响应通知
#pragma mark keyboard notification
- (void)keyboardWillShow:(NSNotification *) notification {
float animationDuration = [[[notificationuserInfo] valueForKey:UIKeyboardAnimationDurationUserInfoKey]floatValue];
CGFloat height = [[[notification userInfo] objectForKey:UIKeyboardFrameEndUserInfoKey]CGRectValue].size.height;
CGRect bottomBarFrame = self.mToolBar.frame;
{
[UIViewbeginAnimations:@"bottomBarUp"context:nil];
[UIView setAnimationDuration: animationDuration];
[UIViewsetAnimationCurve:UIViewAnimationCurveEaseInOut];
bottomBarFrame.origin.y =self.view.bounds.size.height -44 - height;
self.mToolBar.frame = bottomBarFrame;
[UIViewcommitAnimations];
}
}
- (void)keyboardWillHide:(NSNotification *) notification {
float animationDuration = [[[notificationuserInfo] valueForKey:UIKeyboardAnimationDurationUserInfoKey]floatValue];
CGFloat height = [[[notification userInfo] objectForKey:UIKeyboardFrameEndUserInfoKey]CGRectValue].size.height;
CGRect bottomBarFrame = self.mToolBar.frame;
if (bottomBarFrame.origin.y <300)
{
[UIViewbeginAnimations:@"bottomBarDown"context:nil];
[UIView setAnimationDuration: animationDuration];
[UIViewsetAnimationCurve:UIViewAnimationCurveEaseInOut];
bottomBarFrame.origin.y += height;
self.mToolBar.frame = bottomBarFrame;
[UIViewcommitAnimations];
}
}
- iOS相应键盘高度变化,相应控件随之变化的代码段
- 【代码笔记】iOS-屏幕根据键盘自动的变化高度
- 适应ios中键盘高度的变化
- Activiti5流程基本代码,以及相应数据库的变化
- [ios] 适应键盘高度变化
- 获取键盘的高度变化
- 对 键盘 事件 监听NSNotification 处理相应页面 变化UIKeyboardAnimation
- 对 键盘 事件 监听NSNotification 处理相应页面 变化UIKeyboardAnimation
- 对 键盘 事件 监听NSNotification 处理相应页面 变化UIKeyboardAnimation
- iOS UITextField随着键盘的高度变化动态调整位置
- iOS开发之监听键盘高度的变化
- iOS开发之监听键盘高度的变化
- iOS 中键盘上工具栏高度的变化
- iOS开发中的键盘高度变化处理
- iOS开发中的键盘高度变化处理
- 完美适应iOS中的键盘高度变化
- iOS开发中的键盘高度变化处理
- 适应iOS中的键盘高度变化
- .[转] 全国主体功能区规划图
- 谈谈计划任务
- UML类图的6种关系
- VS2010中打开VS2012的项目
- C#操作Excel文件(读取Excel,写入Excel)
- iOS相应键盘高度变化,相应控件随之变化的代码段
- 黑马程序员-IO流其他流对象
- 截取屏幕的实现方法
- SQL 数据类型大全
- 一些打算
- Change : About QThread
- 每个C程序员应该知道的未定义行为#1/3
- opencv haar 分类器记录
- vc++面试常见问题