I have one UITextView that is at the bottom. When the user clicks on it, I need to animate the view 150 pixels up. I use:
- (void)textViewDidBeginEditing:(UITextView *)textView{
and
- (void)textViewDidEndEditing:(UITextView *)textView{
to do this.
On iOS5, it works fine. But on iOS 4.3, when the view is animated, the content in this UITextView has a few pixels up.
Screenshot: http://cl.ly/1q3e0W2G1M000u1U3w1f
Has anyone had similar problems?
Code:
- (void)textViewDidBeginEditing:(UITextView *)textView{ if([textView.text isEqualToString:@"Placeholder text"]){ textView.text = @""; } [UIView beginAnimations:nil context:NULL]; [UIView setAnimationDelegate:self]; [UIView setAnimationDuration:0.3]; [UIView setAnimationBeginsFromCurrentState:YES]; self.view.frame = CGRectMake(self.view.frame.origin.x, (self.view.frame.origin.y - 150.0), self.view.frame.size.width, self.view.frame.size.height); [UIView commitAnimations]; } - (void)textViewDidEndEditing:(UITextView *)textView{ if([textView.text isEqualToString:@""]){ textView.text = @"Placeholder text"; } [UIView beginAnimations:nil context:NULL]; [UIView setAnimationDelegate:self]; [UIView setAnimationDuration:0.3]; [UIView setAnimationBeginsFromCurrentState:YES]; self.view.frame = CGRectMake(self.view.frame.origin.x, (self.view.frame.origin.y + 150.0), self.view.frame.size.width, self.view.frame.size.height); [UIView commitAnimations]; }
source share