2010-04-07 81 views
1

我在我的基於導航的應用程序中有一個動畫。動畫準備就緒時要做些什麼。

[UIView beginAnimations:nil context:nil]; 
     [UIView setAnimationDuration:1.5]; 
     [UIView setAnimationBeginsFromCurrentState:YES]; 
     [UIView setAnimationTransition:UIViewAnimationTransitionCurlDown 
             forView:self.view cache:YES];   
     [UIImageView commitAnimations]; 

後直接這段代碼我叫

[self.navigationController popViewControllerAnimated:NO]; 

的事情是,我不希望我的彈出之前的ViewController我的動畫已準備就緒。

回答

2

集動畫代表和didStop選擇和流行在didStop方法您的視圖控制器指定:

[UIView beginAnimations:nil context:nil]; 
[UIView setAnimationDuration:1.5]; 
[UIView setAnimationBeginsFromCurrentState:YES]; 
[UIView setAnimationDelegate:self]; 
[UIView setAnimationDidStopSelector:@selector(animationDidStop:finished:context:)]; 

[UIView setAnimationTransition:UIViewAnimationTransitionCurlDown 
             forView:self.view cache:YES];   
[UIImageView commitAnimations]; 

注意,那didStop選擇必須是在文檔中指定的格式(見+ setAnimationDidStopSelector方法在文檔的更多詳情):

選擇應該是以下形式: - (無效)animationDidStop:(的NSString *)animationID完成:(的NSNumber *)完成上下文:(無效*)上下文。

1

您可以設置選擇當動畫完成被稱爲:

[UIView setAnimationDelegate:self]; 
[UIView setAnimationDidStopSelector:@selector(animationDidStop:finished:context:)]; 

而且在選擇調用彈出視圖控制器。

- (void)animationDidStop:(NSString *)animationID finished:(NSNumber *)finished context:(void *)context { 

     // Pop the controller now 
    }