【发布时间】:2011-11-17 13:03:32
【问题描述】:
我有一个位于视图底部的 UITextView。当用户点击它时,我需要将视图设置为 150px 的动画。我正在使用:
- (void)textViewDidBeginEditing:(UITextView *)textView{
和
- (void)textViewDidEndEditing:(UITextView *)textView{
做这个。
在 iOS5 上,它运行良好。但在 iOS 4.3 上,当视图动画化时,此 UITextView 中的内容会上升几个像素。
截图:http://cl.ly/1q3e0W2G1M000u1U3w1f
有人遇到过类似问题吗?
代码:
- (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];
}
【问题讨论】:
标签: iphone ios ios4 ios5 uitextview