5
votes

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?

1
The answers on the question: stackoverflow.com/questions/4869787/… 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
Couldn't get it working.Josh Kahane

1 Answers

0
votes

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