시뮬레이터를 사용하여 물건을 찾을 수 없을 때 StackOverflow에 내 위로 옵션입니다 수 사용자 입력을 입력하기위한 키패드와 텍스트 필드를 위로 이동시켜 키패드가 텍스트 필드를 숨기지 않도록 코드를 작성합니다. 델리게이트를 텍스트 필드에 연결하십시오. 보기에서 한로드
{
[[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];
}
의 중복 가능성 [아이폰 - 키보드가 텍스트 필드를 숨 깁니다] (http://stackoverflow.com/questions/2307200/iphone-keyboard-hides-textfield) – Vladimir