0

I have a UITextView editable when selected appears the keyboard. The problem is that when the text is so big he gets behind the keyboard. How can I solve this problem?

NANNAV
  • 4,875
  • 4
  • 32
  • 50
user1491548
  • 111
  • 1
  • 9
  • You should scroll the view up when KeyBoard is appearing. Use this tutorial to achieve it http://www.cocoawithlove.com/2008/10/sliding-uitextfields-around-to-avoid.html – Sumanth Dec 29 '12 at 12:51
  • possible duplicate of [How to make a UITextField move up when keyboard is present](http://stackoverflow.com/questions/1126726/how-to-make-a-uitextfield-move-up-when-keyboard-is-present) – paulmelnikow Dec 30 '12 at 05:42

3 Answers3

2

move your view up by this code

- (BOOL)textFieldShouldBeginEditing:(UITextField *)textField
{
  //change origin y 
[UIView beginAnimations:nil context:self.view];
            [UIView setAnimationDuration:0.25];
            [self.view setFrame:CGRectMake(0,-150,320,436)];
            [UIView commitAnimations];

}
- (BOOL)textFieldShouldEndEditing:(UITextField *)textField
{
   //reset origin y 
[UIView beginAnimations:nil context:self.view];
            [UIView setAnimationDuration:0.25];
            [self.view setFrame:CGRectMake(0,0,320,436)];
            [UIView commitAnimations];

}

set x and y value according your requirement.

Vishal
  • 556
  • 4
  • 18
0

change base view size when edit UITextField,decrease base view orgin origin y to edit text field

- (BOOL)textFieldShouldBeginEditing:(UITextField *)textField
{
  //change origin y 
}
- (BOOL)textFieldShouldEndEditing:(UITextField *)textField
{
   //reset origin y 
}
NANNAV
  • 4,875
  • 4
  • 32
  • 50
0

Use the delegate methods of UITextfield.

- (BOOL)textFieldShouldBeginEditing:(UITextField *)textField
{
            [UIView beginAnimations:nil context:self.view];
            [UIView setAnimationDuration:duration];
            //change origin y 
            [self.view setFrame:CGRectMake(X,newY,width,height)];
            [UIView commitAnimations];

}
- (BOOL)textFieldShouldEndEditing:(UITextField *)textField
{
            [UIView beginAnimations:nil context:self.view];
            [UIView setAnimationDuration:duration];
            //reset origin y 
            [self.view setFrame:CGRectMake(X,Y,width,height)];
            [UIView commitAnimations];
}

Don't forget to set the UITextFieldDelegate in your ".h" file and the appropriate text fileds textfiled.delegate = self.

Shabib
  • 1,697
  • 4
  • 20
  • 39