控件上移 之 虚拟键盘挡住UITextFiled控件
来源:互联网 发布:painter软件怎么用 编辑:程序博客网 时间:2024/04/29 15:54
一些视图中用到了好多文本框,但是文本框挡住了我控件,所以呢下面3个方法就能解决这个问题哦
- (void)keyboardWillShow:(NSNotification *)noti
{
//键盘输入的界面调整
//键盘的高度
float height = 216.0;
CGRect frame = self.userPass.superview.frame;
frame.size = CGSizeMake(frame.size.width, frame.size.height - height);
[UIView beginAnimations:@"Curl"context:nil];//动画开始
[UIView setAnimationDuration:0.30];
[UIView setAnimationDelegate:self];
[self.view setFrame:frame];
[UIView commitAnimations];
}
-(BOOL)textFieldShouldReturn:(UITextField *)textField
{
// When the user presses return, take focus away from the text field so that the keyboard is dismissed.
NSTimeInterval animationDuration = 0.30f;
[UIView beginAnimations:@"ResizeForKeyboard" context:nil];
[UIView setAnimationDuration:animationDuration];
CGRect rect = CGRectMake(0.0f, 0.0f, self.view.frame.size.width, self.view.frame.size.height);
self.view.frame = rect;
[UIView commitAnimations];
[textField resignFirstResponder];
return YES;
}
- (void)textFieldDidBeginEditing:(UITextField *)textField
{
NSLog(@"%@",textField.superview);
CGRect frame = textField.superview.frame;
int offset = frame.origin.y + textField.bottom+10 - (self.view.frame.size.height - 216.0);//键盘高度216
NSTimeInterval animationDuration = 0.30f;
[UIView beginAnimations:@"ResizeForKeyBoard" context:nil];
[UIView setAnimationDuration:animationDuration];
float width = self.view.frame.size.width;
float height = self.view.frame.size.height;
if(offset > 0)
{
CGRect rect = CGRectMake(0.0f, -offset,width,height);
self.view.frame = rect;
}
[UIView commitAnimations];
}
0 0
- 控件上移 之 虚拟键盘挡住UITextFiled控件
- 解决虚拟键盘挡住控件
- iOS键盘弹出的时候会挡住底部的控件,可以通过以下方法将整个UIView上移。
- 如何不让键盘挡住UITextField控件
- 如何不让键盘挡住UITextField控件
- 如何不让键盘挡住UITextField控件
- 如何不让键盘挡住UITextField控件
- 点击键盘,控件上移的方式
- iOS 控件之UITextField及键盘挡住处理方法(欢迎大家提建议和分享)
- 04-常用UI控件之 UIlable UIButton UITextFiled
- iOS:UITextFiled控件的设置
- 整个画面上移,使键盘不挡住画面,去除键盘
- 设置虚拟键盘弹出改变控件问题
- 虚拟键盘遮挡popwindow的控件
- js上移下移控件
- ios7学习之路七(隐藏虚拟键盘,解决键盘挡住UITextField问题)
- UITextField 被键盘挡住时自动上移调整textField frame
- textField被虚拟键盘挡住解决方法
- 敏锐的分析,一个新的文件分析公司,是赢家保持作为一个买家
- Java学习笔记(一)初识Java
- HDU 2819 行列匹配 输出解
- LeetCode Single Number
- NSViewAnimation视图的简单动画
- 控件上移 之 虚拟键盘挡住UITextFiled控件
- 最小生成树之prim算法 原理
- 搬过来Terrasse餐厅文化蒙特利尔 - 庭院餐厅在Oakville
- HDOJ 1001 Sum Problem
- 按照你的网站的访问量借助于谷歌分析
- Qt编程25:QDirModel与QTreeView使用显示目录结构
- 关于轻重缓急
- 并查集小结
- ZOJ 3714 Java Beans