How to do the flip animation between two UIViewControllers while clicking info button? How to do the flip animation between two UIViewControllers while clicking info button? ios ios

How to do the flip animation between two UIViewControllers while clicking info button?


To flip into a view controller:

viewController.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;[self presentViewController:viewController animated:YES completion:nil];

To flip out of it:

[self dismissViewControllerAnimated:YES completion:nil];


This is how I'm doing it:

 AboutShowViewController *aboutShowViewController = [[AboutShowViewController alloc] initWithNibName:@"AboutShowViewController" bundle:[NSBundle mainBundle]];    [UIView beginAnimations:@"View Flip" context:nil];    [UIView setAnimationDuration:0.80];    [UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];    [UIView setAnimationTransition:UIViewAnimationTransitionFlipFromRight                            forView:self.navigationController.view cache:NO];    [self.navigationController pushViewController:aboutShowViewController animated:YES];    [UIView commitAnimations];    [aboutShowViewController release];

Credit goes to faysar here.


There is a fundamental flaw in your understanding of the MVC structure in Cocoa Touch, which is, View Controllers and Views are comparable and similar. The truth is, they are Not.

Back to your specific question, yes, animations are based on views, not on view controllers. But each view should be controlled by one of your view controllers. And this which-view-belongs-to-which-controller thing is totally up to you. In your case, animation could happen between 2 views with 2 different controllers, or, they could also happen between 2 views of the same controller.

As for code samples, I suggest you take a look at one of Xcode's default templates, the Utility Application, which has implemented this click-and-flip animation in a succinct and standardized way.