iOS-键盘弹出遮挡问题
来源:互联网 发布:余额宝 理财通 知乎 编辑:程序博客网 时间:2024/06/05 17:39
- (void)viewDidLoad {
[super viewDidLoad];
//增加监听,当键盘出现或改变时收出消息
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(keyboardWillShow:)
name:UIKeyboardWillShowNotification
object:nil];
//增加监听,当键退出时收出消息
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(keyboardWillHide:)
name:UIKeyboardWillHideNotification
object:nil];
}
//当键盘出现或改变时调用
- (void)keyboardWillShow:(NSNotification *)aNotification
{
//获取键盘的高度
NSDictionary *userInfo = [aNotification userInfo];
NSValue *aValue = [userInfo objectForKey:UIKeyboardFrameEndUserInfoKey];
CGRect keyboardRect = [aValue CGRectValue];
int height = keyboardRect.size.height;
// NSLog(@"%d",height);
NSTimeInterval animationDuration =0.30f;
[UIView setAnimationDuration:animationDuration];
float width = self.view.frame.size.width;
float vheight = self.view.frame.size.height;
CGRect rect = CGRectMake(0.0f, -height,width,vheight);
self.view.frame = rect;
}
//当键退出时调用
- (void)keyboardWillHide:(NSNotification *)aNotification
{
self.view.frame = CGRectMake(0,0, 320, 568);
}
//释放第一响应者
-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event{
[_textview resignFirstResponder];
}
- iOS-键盘弹出遮挡问题
- iOS键盘弹出遮挡输入框问题
- iOS 键盘遮挡问题
- iOS 键盘遮挡问题
- ios键盘遮挡问题
- iOS 解决autolayout下键盘弹出遮挡问题
- 解决iOS键盘弹出遮挡输入框问题
- iOS解决键盘弹出遮挡输入框问题
- iOS 键盘弹出遮挡UITextField解决方法
- ios键盘遮挡UITextField问题
- iOS解决键盘遮挡问题
- iOS 解决键盘遮挡问题
- iOS解决键盘遮挡问题
- ios 处理键盘遮挡问题
- 解决键盘弹出遮挡TextField问题
- 键盘弹出高度和遮挡问题
- android键盘弹出、关闭、遮挡问题
- iOS讲解迷惑之键盘弹出遮挡输入框的问题
- volatile
- 递归与分治:快速排序法
- 《开源框架那点事儿19》:特斯拉建“桩”与开源的生命力
- MongoDB常用操作命令大全
- HTTP服务器头部信息
- iOS-键盘弹出遮挡问题
- 时间处理工具
- SimpleAdapter、GridView简易使用实现九宫格实例
- Windows server2012 AD 备份与恢复(Part2)
- Summary Ranges(数组中连续的数字段)
- 今天碰到一个URL传递中文参数到后台的乱码问题
- HTML 标签 <body>
- Leetcode|3 sum
- 更改Android应用程序的图标