我有一个UIView。里面,我有两个文本字段 - username
和password
,和一个submit
UIButton。我把我的UIView放在屏幕的中心。所以现在当我编辑我的username and password field
时,我的密码字段被键盘隐藏了。当我们编辑UITextField时,移动带有一些UITextFields的UIView
所以当我的键盘打开时,可以显示我的“带有这两个文本字段的全部UIView”?
请帮助一些code.Thanks!
更新的代码:
@implementation ViewController
@synthesize scrollView;
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
-(void)textFieldDidBeginEditing:(UITextField *)textField {
self.scrollView.contentSize = CGSizeMake(self.scrollView.contentSize.width, (self.scrollView.contentSize.height + 260));
self.scrollView.contentOffset = CGPointMake(0,120);
}
-(void)textFieldDidEndEditing:(UITextField *)textField {
self.scrollView.contentOffset = CGPointZero;
self.scrollView.contentSize = CGSizeMake([UIScreen mainScreen].bounds.size.width, [UIScreen mainScreen].bounds.size.height);
}
这已经回答了 –
iarumas
[如何使UITextField在键盘存在时向上移动]的可能重复(http://stackoverflow.com/questions/1126726/how-to-make-a-uitextfield-move-当键盘出现时) –