2009-05-27 41 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