防止键盘遮挡
来源:互联网 发布:otc焊接机器人编程ppt 编辑:程序博客网 时间:2024/05/22 01:18
offset = originYTF + heightTF + heightKeyboard + view.orginY - view.height;
1,把内容都放在view中,然后判断会不会遮挡到,会的话向上移动一定距离。
#pragma mark UITextFieldDelegate
- (BOOL)textFieldShouldReturn:(UITextField *)textField
{
switch (textField.returnKeyType) {
caseUIReturnKeyNext:
if(textField == _tfPhone){
[_tfCompany becomeFirstResponder];
} else if(textField ==_tfCompany){
[_tfAddress becomeFirstResponder];
}else if(textField ==_tfAddress){
[_tfBrand becomeFirstResponder];
}else if(textField ==_tfBrand){
[_tfWays becomeFirstResponder];
}else if(textField ==_tfWays){
[_tfPerson becomeFirstResponder];
}
break;
caseUIReturnKeyDone:
if(textField == _tfPerson){
NSTimeInterval animationDuration =0.30f;
[UIView beginAnimations:@"ResizeForKeyboard"context:nil];
[UIView setAnimationDuration:animationDuration];
CGRect rect =CGRectMake(self.view.frame.origin.x,64.0f,self.view.frame.size.width,self.view.frame.size.height);
self.view.frame = rect;
[UIView commitAnimations];
[textField resignFirstResponder];
[self onSubmit:nil];
}
break;
default:
break;
}
return YES;
}
- (void)textFieldDidBeginEditing:(UITextField *)textField {
NSTimeInterval animationDuration = 0.30f;
[UIView beginAnimations:@"ResizeForKeyBoard"context:nil];
[UIView setAnimationDuration:animationDuration];
float offset = textField.frame.origin.y + textField.frame.size.height + self.view.frame.origin.y +320 -self.view.window.frame.size.height;
if (offset > 0) {
CGRect rect = CGRectMake(self.view.frame.origin.x,self.view.frame.origin.y - offset,self.view.frame.size.width,self.view.frame.size.height);
self.view.frame = rect;
}
[UIView commitAnimations];
}
2,在view中加一个和view一样大小的UIScrollView,在scrollview的滑动的委托方法中隐藏键盘,其他和上面的一样。
#pragma UIScrollViewDelegate
- (void)scrollViewWillBeginDragging:(UIScrollView *)scrollView {
[self.tfPhoneresignFirstResponder];
[self.tfCompanyresignFirstResponder];
[self.tfAddressresignFirstResponder];
[self.tfBrandresignFirstResponder];
[self.tfWaysresignFirstResponder];
[self.tfPersonresignFirstResponder];
NSTimeInterval animationDuration = 0.30f;
[UIView beginAnimations:@"ResizeForKeyboard"context:nil];
[UIView setAnimationDuration:animationDuration];
CGRect rect = CGRectMake(self.view.frame.origin.x,64.0f,self.view.frame.size.width,self.view.frame.size.height);
self.view.frame = rect;
[UIView commitAnimations];
}
3,在view中加一个和view一样大小的UIScrollView,然后判断会不会遮挡到,会的话把view向上移动一定距离,并且把scrollview的contensize拉长键盘高度。
4,在view中加一个和view一样大小的UIScrollView,然后判断会不会遮挡到,把scrollview的contensize拉长键盘高度,并把scrollview scroll到一定的位置
- TextField防止键盘遮挡
- 防止键盘遮挡
- IOS 防止键盘遮挡文本框
- iOS防止键盘的遮挡
- 防止键盘弹出遮挡编辑窗
- UITextField防止键盘遮挡以及添加手势操作消失键盘
- iOS 隐藏键盘,输入法,防止遮挡输入框
- UITableView上的UITextField防止被键盘遮挡
- 新第三方库,防止键盘遮挡输入框
- React-Native学习之 防止键盘遮挡TextInput
- 键盘遮挡
- 键盘遮挡
- (二)UITabBar and UINavigationController基础教程之UITextField键盘隐藏及防止键盘遮挡
- 【IOS沉思录】IOS开发键盘显示、隐藏事件实现输入框调整防止键盘遮挡
- iOS TextField 弹出键盘时实现view整体上移下移:防止弹出键盘遮挡输入框
- 键盘退出方式 键盘遮挡
- textView键盘遮挡问题
- 键盘遮挡问题解决办法
- 搭建属于您自己的软件版本控制
- SDR TF
- Geeks面试题:Min Cost Path
- 张亮上《大咖》秀美腿又卖萌 不再是丑女人
- 专业及学位问题
- 防止键盘遮挡
- Android按两次返回键退出程序
- Altera usb blaster 制作(绝对详细资料)
- poj1529Shipping Routes(floyd)
- Netty4学习笔记(5)-- NioEventLoopGroup继承层次结构
- Sweet Snippet系列 之 随机选择
- hadoop初学
- qt使用ptlib和opal
- viewpager左右循环滑动