2010-04-29 79 views
0

我已將viewcontroller與多視圖配合使用。 當我回到以前,沒有動畫 我有以下行的代碼試過,如何在轉到上一個視圖時獲得動畫

-(IBAction)goback 
{ 
[UIView beginAnimations:nil context:NULL]; 
[UIView setAnimationDuration:1]; 
[UIView setAnimationTransition: UIViewAnimationTransitionCurlDown forView:self.view cache:YES]; 
[self.view removeFromSuperview]; 
[UIView commitAnimations]; 
} 

回答

1

你不能動畫的方法調用。您只能爲視圖的屬性(如框架,大小,alpha等)設置動畫效果。removeFromSuperview不是屬性,它是一種簡單地找到超級視圖並從子視圖數組中移除原始視圖的方法。

您需要運行動畫,然後在動畫完成時發送removeFromSuperview

0

使用下面的代碼

[UIView beginAnimations:nil context:NULL]; 
    [UIView setAnimationDuration:1]; 
    [UIView setAnimationTransition:UIViewAnimationTransitionCurlDown forView:self.view.superview cache:YES]; 
    [self.view removeFromSuperview];  
    [UIView commitAnimations]; 
+0

這是多視圖應用 – user328895 2010-05-13 10:31:03

+0

@jaydp真正的答案:因爲它是你的問題,爲什麼不選它作爲答案,如果它是正確的嗎? – 2010-05-13 11:43:50

相關問題