键盘弹出高度和遮挡问题
来源:互联网 发布:竞价排名优化方法 编辑:程序博客网 时间:2024/04/30 06:03
#import "LoginViewController.h"
#import "ClssNameViewController.h"
@interface LoginViewController ()<UITextFieldDelegate>
@property (strong,nonatomic) IBOutletUIButton *buttonLogin;
@property (strong,nonatomic) IBOutletUITextField *textName;
@property (strong,nonatomic) IBOutletUITextField *textPwd;
@property (strong,nonatomic) IBOutletUITextField *textSelect;
@end
@implementation LoginViewController
-(void)viewDidAppear:(BOOL)animated
{
[superviewDidAppear:animated];
[[NSNotificationCenterdefaultCenter] addObserver:self
selector:@selector(keyboardDidShowOrHide:)
name:UIKeyboardWillShowNotification
object:nil];
[[NSNotificationCenterdefaultCenter] addObserver:self
selector:@selector(keyboardDidShowOrHide:)
name:UIKeyboardWillHideNotification
object:nil];
}
-(void)viewWillDisappear:(BOOL)animated
{
[superviewWillDisappear:animated];
[[NSNotificationCenterdefaultCenter] removeObserver:self];
}
#pragma mark - Keyboard methods
/*
view将要上升的高度= 键盘高度-(屏幕高度- 文本框在view上的y坐标);
*/
-(void)keyboardDidShowOrHide:(NSNotification *)notification
{
NSDictionary *userInfo = [notification userInfo];
NSTimeInterval animationDuration;
UIViewAnimationCurve animationCurve;
CGRect keyboardEndFrame;//键盘的frame
[[userInfoobjectForKey:UIKeyboardAnimationCurveUserInfoKey]getValue:&animationCurve];
[[userInfoobjectForKey:UIKeyboardAnimationDurationUserInfoKey]getValue:&animationDuration];
[[userInfoobjectForKey:UIKeyboardFrameEndUserInfoKey]getValue:&keyboardEndFrame];
[UIViewbeginAnimations:nilcontext:nil];
[UIViewsetAnimationDuration:animationDuration];
[UIViewsetAnimationCurve:animationCurve];
CGRect newFrame = self.view.frame;//view的frame
if (self.textSelect ==nil) {
newFrame.origin.y =0.0;
}
else
{
newFrame.origin.y = keyboardEndFrame.origin.y - newFrame.size.height;
}
self.view.frame = newFrame;
[UIViewcommitAnimations];
}
- (BOOL)textFieldShouldBeginEditing:(UITextField *)textField
{
self.textSelect = textField;
return YES;
}
- (void)viewDidLoad {
[superviewDidLoad];
// Do any additional setup after loading the view.
self.textPwd.delegate =self;
self.textName.delegate =self;
UIImageView* imageViewTap = (UIImageView* )[self.viewviewWithTag:1];
imageViewTap.userInteractionEnabled =YES;
UITapGestureRecognizer* tap = [[UITapGestureRecognizeralloc] initWithTarget:selfaction:@selector(tapConcelText:)];
[imageViewTapaddGestureRecognizer:tap];
}
-(void)tapConcelText:(UITapGestureRecognizer*)tap
{
self.textSelect =nil;
[self.textPwdresignFirstResponder];
[self.textNameresignFirstResponder];
}
@end
- 键盘弹出高度和遮挡问题
- 解决键盘弹出遮挡TextField问题
- iOS-键盘弹出遮挡问题
- iOS键盘弹出遮挡输入框问题
- android键盘弹出、关闭、遮挡问题
- iOS 解决autolayout下键盘弹出遮挡问题
- 解决iOS键盘弹出遮挡输入框问题
- iOS解决键盘弹出遮挡输入框问题
- android虚拟键盘弹出遮挡登陆按钮问题
- 处理键盘消失和遮挡的问题
- UITextField被弹出键盘遮挡
- iOS 输入框弹出键盘后改变tableView高度内容不被遮挡
- 输入框弹出输入法高度自适应(遮挡键盘,自动反弹)
- textView键盘遮挡问题
- uitextfield键盘遮挡问题
- UIScrollview 键盘遮挡问题
- 键盘遮挡问题(UITextField)
- iOS 键盘遮挡问题
- swift中的函数的使用,嵌套
- ActiveMQ讯息策略
- 重写equals方法和hashcode方法
- 【Mockplus教程】分组
- zookeeper的基本分布式工作原理
- 键盘弹出高度和遮挡问题
- 名词解释---Bitrate/比特率
- IOS开发通过代码方式使用AutoLayout (NSLayoutConstraint + Masonry)
- Φ字母来源
- 从什么是 Bluemix 说起
- Android 清空输入框内容
- iOS 9 下周就正式推出了,你的 app 真的适配好了吗?
- android studio 添加.so依赖
- Spark与Flink:对比与分析