2012-04-22 6 views
0

전체 화면을 가져 오는 10 개의 UITextField가 있습니다. 내가 그들을 바꿀 때, 화면 절반에 키패드가 생기므로, 나는 숨겨진 필드를 바꿀 수 없다. 솔루션을 아는 사람이 있습니까?키패드가 숨어 있습니다. UITextField

+1

텍스트 필드를 스크롤 할 수 있으며 텍스트 필드를 클릭 할 때마다 키보드가 나타납니다. – rishi

답변

1

키보드를 불러 와서 프레임을 위로 올려야합니다.

- (void)keyboardWillShow:(NSNotification *)aNotification 
{ 
    self.frame = CGRectMake(0,-[size of keyboard],self.frame.size.width,self.frame.size.height); 
} 
0

i have taken from here :

- (void)textFieldDidBeginEditing:(UITextField *)textField { 
    if (textField == textField1) { 
     [UIView beginAnimations:nil context:NULL]; 
     [UIView setAnimationDelegate:self]; 
     [UIView setAnimationDuration:0.5]; 
     [UIView setAnimationBeginsFromCurrentState:YES]; 
     textfield1.frame = CGRectMake(textfield1.frame.origin.x, (textfield1.frame.origin.y - 100.0), textfield1.frame.size.width, textfield1.frame.size.height); 
     [UIView commitAnimations]; 
    } else if (textField == textField2) { 
     [UIView beginAnimations:nil context:NULL]; 
     [UIView setAnimationDelegate:self]; 
     [UIView setAnimationDuration:0.5]; 
     [UIView setAnimationBeginsFromCurrentState:YES]; 
     textfield2.frame = CGRectMake(textfield2.frame.origin.x, (textfield2.frame.origin.y - 100.0), textfield2.frame.size.width, textfield2.frame.size.height); 
     [UIView commitAnimations]; 
    } 
} 
- (void)textFieldDidEndEditing:(UITextField *)textField { 
    if (textField == textField1) { 
     [UIView beginAnimations:nil context:NULL]; 
     [UIView setAnimationDelegate:self]; 
     [UIView setAnimationDuration:0.5]; 
     [UIView setAnimationBeginsFromCurrentState:YES]; 
     textfield1.frame = CGRectMake(textfield1.frame.origin.x, (textfield1.frame.origin.y + 100.0), textfield1.frame.size.width, textfield1.frame.size.height); 
     [UIView commitAnimations]; 
    } else if (textField == textField2) { 
     [UIView beginAnimations:nil context:NULL]; 
     [UIView setAnimationDelegate:self]; 
     [UIView setAnimationDuration:0.5]; 
     [UIView setAnimationBeginsFromCurrentState:YES]; 
     textfield2.frame = CGRectMake(textfield2.frame.origin.x, (textfield2.frame.origin.y + 100.0), textfield2.frame.size.width, textfield2.frame.size.height); 
     [UIView commitAnimations]; 
    } 

터치에

:

- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event 

{[텍스트 필드 resignFirstResponder]; }

희망이 도움이 될 것입니다.
도와 드리겠습니다.