显示或隐藏键盘改变tableView高度
来源:互联网 发布:生气 知乎 编辑:程序博客网 时间:2024/06/10 20:14
- (void)registerKeybordNotification
{
NSNotificationCenter *notification = [NSNotificationCenter defaultCenter];
[notification removeObserver:self];
[notification addObserver:self
selector:@selector(showKeyboard:)
name:UIKeyboardWillShowNotification
object:nil];
[notification addObserver:self
selector:@selector(hideKeyboard:)
name:UIKeyboardWillHideNotification
object:nil];
#ifdef __IPHONE_5_0
// 5.0以上系统中文键盘高度与4.0系统不一样
float version = [[[UIDevice currentDevice] systemVersion] floatValue];
if (version >= 5.0) {
[notification addObserver:self
selector:@selector(showKeyboard:)
name:UIKeyboardWillChangeFrameNotification
object:nil];
}
#endif
}
- (void)showKeyboard:(NSNotification *)notification
{
NSDictionary *userInfo = [notification userInfo];
NSValue *aValue = [userInfo objectForKey:UIKeyboardFrameEndUserInfoKey];
CGFloat keyboardHeight = CGRectGetHeight([aValue CGRectValue]);
CGFloat height = CGRectGetHeight(self.view.frame) - self.barHeight - keyboardHeight;
/* 使用动画效果,过度更加平滑 */
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:0.1];
{
CGRect rect = _tableView.frame;
rect.size.height = height;
_tableView.frame = rect;
}
[UIView commitAnimations];
}
- (void)hideKeyboard:(NSNotification *)notification
{
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:0.1];
{
CGRect rect = _tableView.frame;
rect.size.height = CGRectGetHeight(self.view.frame) - self.barHeight;
_tableView.frame = rect;
}
[UIView commitAnimations];
}
{
NSNotificationCenter *notification = [NSNotificationCenter defaultCenter];
[notification removeObserver:self];
[notification addObserver:self
selector:@selector(showKeyboard:)
name:UIKeyboardWillShowNotification
object:nil];
[notification addObserver:self
selector:@selector(hideKeyboard:)
name:UIKeyboardWillHideNotification
object:nil];
#ifdef __IPHONE_5_0
// 5.0以上系统中文键盘高度与4.0系统不一样
float version = [[[UIDevice currentDevice] systemVersion] floatValue];
if (version >= 5.0) {
[notification addObserver:self
selector:@selector(showKeyboard:)
name:UIKeyboardWillChangeFrameNotification
object:nil];
}
#endif
}
- (void)showKeyboard:(NSNotification *)notification
{
NSDictionary *userInfo = [notification userInfo];
NSValue *aValue = [userInfo objectForKey:UIKeyboardFrameEndUserInfoKey];
CGFloat keyboardHeight = CGRectGetHeight([aValue CGRectValue]);
CGFloat height = CGRectGetHeight(self.view.frame) - self.barHeight - keyboardHeight;
/* 使用动画效果,过度更加平滑 */
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:0.1];
{
CGRect rect = _tableView.frame;
rect.size.height = height;
_tableView.frame = rect;
}
[UIView commitAnimations];
}
- (void)hideKeyboard:(NSNotification *)notification
{
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:0.1];
{
CGRect rect = _tableView.frame;
rect.size.height = CGRectGetHeight(self.view.frame) - self.barHeight;
_tableView.frame = rect;
}
[UIView commitAnimations];
}
- 显示或隐藏键盘改变tableView高度
- 显示或隐藏键盘改变tableView高度
- iOS、Xcode监测键盘的显示和隐藏变化,并获得键盘高度,改变tableView的frame和偏移
- iPhone获取键盘高度,通知方式隐藏和显示键盘
- iOS 键盘显示或消失的监听,获取键盘高度
- iOS 输入框弹出键盘后改变tableView高度内容不被遮挡
- tableviewcell 自动调整textfiled的键盘遮挡问题 UITableViewController中的tableview做可以自适应键盘高度来改变tableview的额外高度。
- iOS开发监听键盘(添加键盘和隐藏键盘,改变视图中整体控件随着键盘的高度移动)
- 动态修改EditText输入键盘并隐藏或显示密码
- ios 键盘高度改变通知
- android 隐藏键盘 显示键盘
- 隐藏键盘和显示键盘
- 动态改变tableview的cell的高度
- iOS 改变TableHeadView的高度,tableView自适应
- 隐藏和显示tableview.tableheaderview
- 显示、隐藏虚拟键盘
- 键盘显示隐藏控制
- 键盘显示隐藏
- poj 3260 多重背包+完全背包
- dom总结(2012.11.30)
- 第11讲 tcp ip基础
- mysql 1005-Can't create table ''error:121&mysql error 1005 can't create table'<errno:150>
- cat /proc/cpuinfo
- 显示或隐藏键盘改变tableView高度
- MongoDB学习笔记(五) MongoDB文件存取操作
- UML图之静态图
- 初级->图算法->最短路 poj 1125 Stockbroker Grapevine
- Flex中多线程的实现 ( 转 )
- 程序员面试题精选100题(47)-数组中出现次数超过一半的数字
- 开源SVM库libSVM介绍
- DOM 在js中的使用(2012.11.30)
- Hadoop学习笔记-Hadoop在Windows下安装