1) set delegate to you textFields
[self.textField setDelegate:self];
2) To move textField up
-(void)textFieldDidBeginEditing:(UITextField *)textField
{
if (textField == self.textField)
{
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDelegate:self];
[UIView setAnimationDuration:0.5];
[UIView setAnimationBeginsFromCurrentState:YES];
self.view.frame = CGRectMake(self.view.frame.origin.x , (self.view.frame.origin.y - 80), self.view.frame.size.width, self.view.frame.size.height);
[UIView commitAnimations];
}
}
3) To move textField down
-(void)textFieldDidEndEditing:(UITextField *)textField
{
if (textField == self.textField)
{
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDelegate:self];
[UIView setAnimationDuration:0.5];
[UIView setAnimationBeginsFromCurrentState:YES];
self.view.frame = CGRectMake(self.view.frame.origin.x , (self.view.frame.origin.y + 80), self.view.frame.size.width, self.view.frame.size.height);
[UIView commitAnimations];
}
}
4) to move textView Up
-(void)textViewDidBeginEditing:(UITextView *)textView
{
if (textView == self.textView)
{
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDelegate:self];
[UIView setAnimationDuration:0.5];
[UIView setAnimationBeginsFromCurrentState:YES];
self.view.frame = CGRectMake(self.view.frame.origin.x , (self.view.frame.origin.y - 80), self.view.frame.size.width, self.view.frame.size.height);
[UIView commitAnimations];
}
}
5) to move textView Down
-(void)textViewDidEndEditing:(UITextView *)textView
{
if (textView == self.textView)
{
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDelegate:self];
[UIView setAnimationDuration:0.5];
[UIView setAnimationBeginsFromCurrentState:YES];
self.view.frame = CGRectMake(self.view.frame.origin.x , (self.view.frame.origin.y + 80), self.view.frame.size.width, self.view.frame.size.height);
[UIView commitAnimations];
}
}
Sign up here with your email
ConversionConversion EmoticonEmoticon