Skip to content

Instantly share code, notes, and snippets.

@autresphere
Created April 3, 2013 11:49
Show Gist options
  • Save autresphere/5300529 to your computer and use it in GitHub Desktop.
Save autresphere/5300529 to your computer and use it in GitHub Desktop.
How to handle view controller transitions with an animated: flag (http://khanlou.com/2013/03/animations-with-an-animated-flag/). Another solution much simpler.
- (void) pushViewController:(UIViewController *)viewController animated:(BOOL)animated {
newViewController.view.frame = //original frame
[self addChildViewController:newViewController];
[self transitionFromViewController:oldViewController
toViewController:newViewController
duration:(animated?0.35f:0)
options:0
animations:^{
newViewController.view.frame = //new frame
}
completion:^(BOOL finished) {
[newViewController didMoveToParentViewController:self];
}];
}
@autresphere
Copy link
Author

From Apple doc for [UIViewController transitionFromViewController:toViewController:duration:options:animations:completion:]
duration: If you pass zero, the changes are made without animating them.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment