键盘弹出时textfield也随着上移,键盘隐藏时,textfield回到原来的位置
2015-01-19 10:31
459 查看
blog.csdn.net/iorchid/article/details/6561862
键盘弹出时textfield也随着上移,键盘隐藏时,textfield回到原来的位置
_tspasswordTF = [[UITextField alloc] initWithFrame: CGRectMake(100, 150, 60, 30)];
_tspasswordTF.backgroundColor = [UIColor redColor];
_tspasswordTF.tag = 2;
_tspasswordTF.delegate = self;
[self.view addSubview: _tspasswordTF];
- (void)textFieldDidBeginEditing:(UITextField *)textField
{
[self animateTextField: textField up: YES];
}
- (BOOL)textFieldShouldReturn:(UITextField *)textField
{
[self animateTextField: textField up: NO];
[textField resignFirstResponder];
return YES;
}
- (void) animateTextField: (UITextField*) textField up: (BOOL) up
{
const int movementDistance = 80; // tweak as needed
const float movementDuration = 0.3f; // tweak as needed
int movement = (up ? -movementDistance : movementDistance);
[UIView beginAnimations: nil context: nil];
[UIView setAnimationBeginsFromCurrentState: YES];
[UIView setAnimationDuration: movementDuration];
self.view.frame = CGRectOffset(self.view.frame, 0, movement);
[UIView commitAnimations];
}
相关文章推荐
- 弹出键盘,textfield上移,搜罗总结
- XZ_iOS中textField的键盘弹出和回收导致的界面上移和下移
- TextField-===注册登陆随着键盘的弹出而上移动(方法1)
- TextField随着键盘的弹出上移
- iOS开发:TextField随着键盘的弹出上移
- 软键盘弹出布局与edittext一起上移
- Android.EditText点击时,隐藏系统弹出的键盘,显示出光标
- 点击某个TextField无法收回所有TextField的键盘,比较特殊(点击的是文本框,而不是done)--iOS 开发
- iOS TextField输入框点击键盘时随着键盘上移
- 解决键盘弹出遮挡TextField问题
- iOS TextField输入框点击键盘时随着键盘上移
- Android.edittext点击时,隐藏系统弹出的键盘,显示出光标
- iOS中,textField弹出键盘时,让整个视图上移,键盘回收,视图收回
- textField,textView中设置弹出的键盘样式和返回键的类型
- edittext弹出键盘或者隐藏键盘
- ios 自定义cell中有textField,点击textField时,防止键盘挡住textField
- IONIC键盘弹出防止页面Header(title位置)自动上移位置(消失)
- iOS模拟器,点击textfield为什么不弹出软键盘
- CCTextFieldTTF ios按return 隐藏键盘
- ios---实现随着键盘弹出,响应的视图也随之上移