user1491548
user1491548

Reputation: 111

IPhone TextView hidden by keyboard

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?

Upvotes: 0

Views: 888

Answers (3)

Shabib
Shabib

Reputation: 1697

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.

Upvotes: 0

Vishal
Vishal

Reputation: 556

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.

Upvotes: 2

NANNAV
NANNAV

Reputation: 4901

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 
}

Upvotes: 0

Related Questions