2009-05-27 36 views
3

我有一個核心動畫塊,我調用了一個將加載視圖控制器的方法。兩個視圖控制器之間存在自定義轉換。但是,當視圖控制器構建界面時,所有這些東西都受核心動畫的影響。雖然它會產生一些有趣的效果,但我不希望那樣;)如何排除核心動畫塊內的一段代碼被動畫化?

[UIView beginAnimations:@"jump to view controller" context:self]; 
[UIView setAnimationDuration:0.55]; 
[UIView setAnimationCurve:UIViewAnimationCurveEaseOut]; 

// some animated property-changes here... 

[self loadViewControllerForIndex:targetIndex]; // everything that happens in this method shall not be animated 

UIViewController *controller = [viewControllers objectAtIndex:targetIndex]; 
[controller viewWillAppear:YES]; 
[controller viewDidAppear:YES]; 

[UIView commitAnimations]; 

不幸的是,我不能將該部分移出塊。

回答

10

您應該能夠通過包裝的那款在CATransaction和禁用動畫爲它打壓了UIView動畫塊的部分動畫:

[CATransaction begin]; 
[CATransaction setValue:(id)kCFBooleanTrue forKey:kCATransactionDisableActions];  

// Changes to disable animation for here 
[CATransaction commit]; 
+0

這難道不是一樣+ CATransaction setDisableActions:是]在動畫塊內? – 2011-08-10 19:35:23