、あなたのシミュレータを使用しますユーザ入力を入力するためのキーパッドと、テキストフィールドを上に移動させるためのコードを書き込んで、キーパッドがテキストフィールドを隠さないようにする。代理人をテキストフィールドに接続します。 、ビューでやった負荷
{
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWillShow:) name:UIKeyboardWillShowNotification object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWillHide:) name:UIKeyboardWillHideNotification object:nil];
}
をして、次の方法
- (void) keyboardWillShow: (NSNotification*) aNotification
{
int position = 0;
if ([txtfld1 isFirstResponder])
position = 120;
else if ([txtfld2 isFirstResponder]) position = 120;
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:0.3];
CGRect rect = [[self view] frame];
rect.origin.y -= position;
[[self view] setFrame: rect];
[UIView commitAnimations];
}
- (void) keyboardWillHide: (NSNotification*) aNotification
{
int position = 0;
if ([txtfld1 isFirstResponder])
position = 120;
else if ([txtfld2 isFirstResponder]) position = 120;
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:0.3];
CGRect rect = [[self view] frame];
rect.origin.y += position;
[[self view] setFrame: rect];
[UIView commitAnimations];
}
の可能重複[iPhoneは - キーボードは、TextFieldを隠す](http://stackoverflow.com/questions/2307200/iphone-keyboard-hides-textfield) – Vladimir