How can I exclude a piece of code inside the main animation block from the animated one?

I have a main animation block where I call a method that will load the view controller. There is a custom transition between two view controllers. However, when the view controller creates an interface, it all depends on the main animation. Although this leads to some interesting effects, I don't want this;)

[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];

Unfortunately, I cannot get this part out of the block.

+3
source share
1 answer

You must be able to suppress the animation for the section of the UIView animation block by wrapping this section in CATransaction and turning off the animation for it:

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

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

All Articles