iOS UITextField输入框随键盘弹出界面上移
2017-09-07 14:48
218 查看
//点击输入框界面跟随键盘上移
- (void)textFieldDidBeginEditing:(UITextField *)textField {
CGRect frame = textField.frame;
int offSet = frame.origin.y +
70 - (self.view.frame.size.height
- 216.0); //iphone键盘高度为216.iped键盘高度为352
[UIView
beginAnimations:@"ResizeForKeyboard"
context:nil];
[UIView
setAnimationDuration:0.5f];
//将试图的Y坐标向上移动offset个单位,以使线面腾出开的地方用于软键盘的显示
if (offSet >
0) {
self.view.frame =
CGRectMake(0.0f, -offSet,
self.view.frame.size.width,
self.view.frame.size.height);
[UIView
commitAnimations];
}
}
//输入框编辑完成以后,将视图恢复到原始状态
- (void)textFieldDidEndEditing:(UITextField *)textField {
self.view.frame =
CGRectMake(0,
0, self.view.frame.size.width,
self.view.frame.size.height);
}
- (void)textFieldDidBeginEditing:(UITextField *)textField {
CGRect frame = textField.frame;
int offSet = frame.origin.y +
70 - (self.view.frame.size.height
- 216.0); //iphone键盘高度为216.iped键盘高度为352
[UIView
beginAnimations:@"ResizeForKeyboard"
context:nil];
[UIView
setAnimationDuration:0.5f];
//将试图的Y坐标向上移动offset个单位,以使线面腾出开的地方用于软键盘的显示
if (offSet >
0) {
self.view.frame =
CGRectMake(0.0f, -offSet,
self.view.frame.size.width,
self.view.frame.size.height);
[UIView
commitAnimations];
}
}
//输入框编辑完成以后,将视图恢复到原始状态
- (void)textFieldDidEndEditing:(UITextField *)textField {
self.view.frame =
CGRectMake(0,
0, self.view.frame.size.width,
self.view.frame.size.height);
}
相关文章推荐
- IOS UITableView中UITextField 弹出键盘时,界面上移
- swift实现ios类似微信输入框跟随键盘弹出的效果
- iOS开发键盘弹出时遮住输入框的问题
- iOS 键盘弹出与回收、界面上移和下移
- iOS UITextField 获得焦点后,阻止弹出键盘事件
- iOS开发>>>UITextField输入框,点击背景任何地方,实现键盘关闭
- UITextField控件处理键盘弹出时遮住输入框的问题(Andy)
- [UI控件问题] UITextField控件处理键盘弹出时遮住输入框的问题
- 修复ios上第三方输入法弹出时输入键盘盖住网页没有进行相应滚动从而盖住表单输入框的问题
- swift实现ios类似微信输入框跟随键盘弹出的效果
- iOS解决键盘弹出遮挡输入框问题
- iOS 输入框弹出键盘后改变tableView高度内容不被遮挡
- iOS 弹出键盘,输入框上移问题
- iOS 监听键盘弹出的高度,避免挡住界面
- IOS开发键盘弹出时遮住输入框的问题的一种解决方法。
- 解决webview中输入框完成输入隐藏键盘后滑动界面又弹出软键盘问题
- iOS 评论界面 监听键盘高度 动态改变输入框位置
- ios开发之uitextview及uitextfield获得焦点时弹出的键盘及键盘上面的附加view设置
- iOS TextField 弹出键盘时实现view整体上移下移:防止弹出键盘遮挡输入框
- IOS学习笔记36—解决键盘遮挡输入框(UITextField)问题