根据键盘调整视图高度
来源:互联网 发布:win7网络控制器有叹号 编辑:程序博客网 时间:2024/05/16 12:32
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWillShow:) name:UIKeyboardWillShowNotification object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWillHide:) name:UIKeyboardWillHideNotification object:nil];
#pragma mark - keybord(监测键盘响应方法)
- (void)keyboardWillShow:(NSNotification *)notification {
NSDictionary *userInfo = [notification userInfo];
NSValue* aValue = [userInfo objectForKey:UIKeyboardFrameEndUserInfoKey];
CGRect keyboardRect = [aValue CGRectValue];
NSNumber *animationDurationValue = [userInfo objectForKey:UIKeyboardAnimationDurationUserInfoKey];
NSTimeInterval animationDuration = [animationDurationValue floatValue];
[self moveInputBarWithKeyboardHeight:keyboardRect.size.height withDuration:animationDuration];
}
- (void)keyboardWillHide:(NSNotification *)notification {
NSDictionary* userInfo = [notification userInfo];
NSValue *animationDurationValue = [userInfo objectForKey:UIKeyboardAnimationDurationUserInfoKey];
NSTimeInterval animationDuration;
[animationDurationValue getValue:&animationDuration];
[self moveInputBarWithKeyboardHeight:0.0 withDuration:animationDuration];
}
#pragma mark - frameChange(根据键盘弹出改变frame)
- (void)moveInputBarWithKeyboardHeight:(float)keyboardHeight withDuration:(NSTimeInterval)animationDuration
{
[UIView animateWithDuration:animationDuration delay:0 options:UIViewAnimationOptionCurveEaseInOut animations:^{
_tableView.frame = CGRectMake(0, 64, SCREEN_WIDTH, self.view.bounds.size.height -keyboardHeight - 44 - 64);
} completion:^(BOOL finished) {
}];
}
- 根据键盘调整视图高度
- 自动根据键盘位置调整UITextView的高度
- ios swift开发中,使用键盘,tableview根据键盘调整高度
- UITextField,键盘弹出高度调整
- iOS根据键盘弹出计算键盘高度
- 获取键盘高度,调整输入框位置
- 根据内容自动调整IFrame高度
- 根据内容调整iframe的高度
- 根据内容调整iframe的高度
- iframe 的高度根据内容自动调整
- 根据内容自动调整iframe框架高度
- 根据内容调整iframe的高度
- showModalDialog根据浏览器自动调整高度
- 根据屏幕的高度宽度,调整大小
- 让UIWebView根据内容自动调整高度
- 根据内容自动调整高度的cell
- 让iframe根据内容自动调整高度~~~
- 根据内容自动调整IFrame高度
- Java: protected访问权限
- Android最新开发环境搭建(Android 5.0)
- android坐标 .
- 兔子--获取app的版本号
- 第八周项目零(2):阅读程序:运算符重载
- 根据键盘调整视图高度
- 一个框架应该包含哪些内容?
- EAX、ECX、EDX、EBX寄存器的作用
- 排序-快排、二分及旋转数组的最小数字
- Android 的NoClassDefFoundError
- 将py文件打包成exe的三种工具方法
- 字典树
- 使用EventBus来实现数据的传递
- Android获取摄像头视频帧并实时处理(转载)