键盘
来源:互联网 发布:怎么打开微信淘宝链接 编辑:程序博客网 时间:2024/04/30 14:38
在看asihttprequest代码时候,无意发现了关于键盘弹出时遮盖页面显示的解决方案,
解决方法如下:
在viewload方法里面注册监听键盘弹出和hide
[[self view] setAutoresizingMask:UIViewAutoresizingFlexibleHeight|UIViewAutoresizingFlexibleWidth];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWillShow:) name:UIKeyboardWillShowNotification object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWillHide:) name:UIKeyboardWillHideNotification object:nil];
然后在keyboardWillShow修改页面的大小- 键盘的高度
- (void)keyboardWillShow:(NSNotification *)notification
{
#if __IPHONE_OS_VERSION_MIN_REQUIRED >= __IPHONE_3_2
NSValue *keyboardBoundsValue = [[notification userInfo] objectForKey:UIKeyboardFrameEndUserInfoKey];
#else
NSValue *keyboardBoundsValue = [[notification userInfo] objectForKey:UIKeyboardBoundsUserInfoKey];
#endif
CGRect keyboardBounds;
[keyboardBoundsValue getValue:&keyboardBounds];
UIEdgeInsets e = UIEdgeInsetsMake(0, 0, keyboardBounds.size.height-42, 0);
[[self tableView] setScrollIndicatorInsets:e];
[[self tableView] setContentInset:e];
}
恢复正常页面
- (void)keyboardWillHide:(NSNotification *)notification
{
UIEdgeInsets e = UIEdgeInsetsMake(0, 0, 0, 0);
[[self tableView] setScrollIndicatorInsets:e];
[[self tableView] setContentInset:e];
}
- 键盘
- 键盘
- 键盘
- 键盘
- 键盘
- 键盘
- 键盘
- 键盘
- 键盘
- 键盘
- 键盘
- 键盘
- 键盘
- 键盘--外语键盘问题
- iOS键盘监控键盘
- 键盘钩子
- 键盘消息
- 键盘键值
- 使用GSON解析json
- Ubuntu新增用户
- 编译protobuf文件
- mysql中表名为关键字的处理方法
- 配置IISExpress允许外部访问
- 键盘
- CenOS安装Oracle 11g
- C#拒绝添加重复信息与关闭提示
- 【玩转cocos2d-x之二十六】数据结构CCDictionary
- 【CODEFORCES】 B. Worms
- Eclipse调试Bug的七种常用技巧
- Android自定义拍照解决部分手机拍完之后图片不清楚的问题
- 关于cocos2dx里面的重力感应事件
- 【玩转cocos2d-x之二十七】CCSequence不能执行CCRepeatForever