我有一個位於視圖底部的UITextView。當用戶點擊它時,我需要動畫視圖150px。我使用的是:UITextView動畫視圖後的內容偏移量不足
- (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];
}
把這段代碼放在哪裏? – dormitkon
謝謝!你也可以使用常量'UIEdgeInsetsZero' – colincameron