2012-04-22 49 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]。 }

希望はあなたを助けます。
お寄せいただきありがとうございます。

関連する問題