Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to change pop view controller animation on back button?

I am pushing my view controller with the following statement :

[[self navigationController] pushViewController:self.customViewController animatedWithTransition:UIViewAnimationTransitionFlipFromLeft];

Now when I am pressing the back button I want to animate it with the uiviewanimationtransitionflipfromright .

like

[self.navigationController popViewControllerAnimatedWithTransition:UIViewAnimationTransitionFlipFromLeft];

How Can I do so ?

Thanks

like image 427
harshalb Avatar asked May 31 '10 08:05

harshalb


3 Answers

This helps you to animating the view in back button.

[UIView  beginAnimations:nil context:NULL];
[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
[UIView setAnimationDuration:0.75];
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromLeft forView:self.navigationController.view cache:NO];
[UIView commitAnimations];

[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDelay:0.375];
[self.navigationController popViewControllerAnimated:NO];
[UIView commitAnimations];
like image 184
Swift-Master Avatar answered Oct 21 '22 22:10

Swift-Master


For Push:

MainView *nextView = [[MainView alloc] init];
[UIView animateWithDuration:0.75
                     animations:^{
                         [UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
                         [self.navigationController pushViewController:nextView animated:NO];
                         [UIView setAnimationTransition:UIViewAnimationTransitionFlipFromRight forView:self.navigationController.view cache:NO];
                     }];

For Pop:

[UIView animateWithDuration:0.75
                     animations:^{
                         [UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
                         [UIView setAnimationTransition:UIViewAnimationTransitionFlipFromLeft forView:self.navigationController.view cache:NO];
                     }];
[self.navigationController popViewControllerAnimated:NO];

https://stackoverflow.com/a/5889757/1915820

like image 39
rilar Avatar answered Oct 21 '22 23:10

rilar


See here for doing custom back anim:

Prevent the animation when clicking "Back" button in a navigation bar?

like image 1
Adam Avatar answered Oct 22 '22 00:10

Adam