5

I have a UINavigationController setup in my storyboard and I have made a custom segue class which you can see below which nicely fades between my views (rather than a bog standard push).

However, when I tap that back button my nav controller gave me, I get a push animation which I don't want, I want to use that fade! I also don't want to have to have segues in my storyboard going both ways as it just gets messy.

Custom fade segue:

-(void)perform
{
    __block UIViewController *sourceViewController = (UIViewController*)[self sourceViewController];
    __block UIViewController *destinationController = (UIViewController*)[self destinationViewController];

    [UIView transitionWithView:sourceViewController.navigationController.view duration:1.0 options:UIViewAnimationOptionTransitionCrossDissolve
                    animations:^
                    {
                        [sourceViewController.navigationController pushViewController:destinationController animated:NO];
                    }
                    completion:^(BOOL finished)
                    {
                        NSLog(@"Transition Completed");
                    }];
}

Edit

Perhaps I should simplify. How can I do a cross dissolve fade between two view controllers in a UINavigationController which pushes and pops views instead of the standard left-right siding animation?

halfer
  • 19,824
  • 17
  • 99
  • 186
Josh Kahane
  • 16,765
  • 45
  • 140
  • 253
  • The answers on the question: http://stackoverflow.com/questions/4869787/uinavigationcontroller-custom-animation seem to indicate that you can customize the 'push' by defining your own pushController function (and therefore overruling the default) within your UINavigationController - Worth trying? (or have you already tried something like this?) – YDL Aug 30 '12 at 17:10
  • Couldn't get it working. – Josh Kahane Aug 30 '12 at 17:56

1 Answers1

0

If you're building for iOS 7 you can use UINavigationControllerDelegate and the new view controller transitioning api's.

Here's a guide: http://www.captechconsulting.com/blog/tyler-tillage/ios-7-tutorial-series-custom-navigation-transitions-more

eunoia
  • 246
  • 2
  • 10