Individual animation of the UINavigationController transition to the back button

I made a custom transition in the UINavigationController, the code I used:

SecondView *newView = [[SecondView alloc] initWithNibName:nil bundle:nil]; [UIView beginAnimtaions:nil context:nil]; [UIView setAnimationDuration:1.0]; [UIView setAnimationTransition:UIViewAnimationTransitionCurlDown]; [self.navigationcontroller pushViewController:newView animated:NO]; [UIView commitAntimations]; [newView release]; 

But this transitional animation only applies to Forward, can I apply it to Back?

thanks

+4
source share
1 answer

Of course, just define a custom UIBarButtonItem for back button and bind it to a custom method that does something like this so that you press the controller, but instead of clicking, you will need to place the view controller.

i.e. first you create a back button (in the init or viewDidLoad method).

 UIBarButtonItem *backBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"Done" style:UIBarButtonItemStyleDone target:self action:@selector(back)]; self.navigationItem.leftBarButtonItem = backBarButtonItem; [backBarButtonItem release]; 

then in your inverse method you can do your own animation

 -(IBAction)back { [UIView beginAnimations:nil context:NULL]; [UIView setAnimationDuration: 1.0]; [UIView setAnimationTransition:UIViewAnimationTransitionCurlUp forView:self.navigationController.view cache:YES]; [[self navigationController] popViewControllerAnimated:NO]; [UIView commitAnimations]; } 
+11
source

All Articles