commscheck commscheck - 1 month ago 21x
Objective-C Question

UIViewControllerTransitioningDelegate method not called in iOS 7

I have created a custom transition animation for a modal view controller by implementing the methods in the


In iOS 8 and 9 the methods are called normally and the transition works. However, in iOS 7, the
method never gets called. The
method still gets called normally.

#import "MyModalTransitioningDelegate.h"
#import "MyModalFadeTransition.h"

@implementation MyModalTransitioningDelegate

- (id<UIViewControllerAnimatedTransitioning>)animationControllerForPresentedController:(UIViewController *)presented
presentingController:(UIViewController *)presenting
sourceController:(UIViewController *)source
return [[MyModalFadeTransition alloc] init];

- (id<UIViewControllerAnimatedTransitioning>)animationControllerForDismissedController:(UIViewController *)dismissed
return [[MyModalFadeTransition alloc] init];


In the modal view controller (i.e. the "presented controller") I have the following in its

self.modalTransitionDelegate = [[OTModalTransitioningDelegate alloc] init]; // This is a custom strong private property due to `tranisitioningDelegate` being a weak property.
self.transitioningDelegate = self.modalTransitionDelegate;
self.modalPresentationStyle = UIModalPresentationCustom;

Setting the
doesn't seem to make any difference in any version of iOS. The method that isn't being called does say that it's available in iOS 7 so I'm not sure why it isn't being called.

The modal view controller is being presented with the following code in the presenting view controller:

[self presentViewController:self.modalViewController


Setting the transitioningDelegate in the presenting view controller's initialiser instead of the viewDidLoad method fixed the issue.

It appears in iOS 7 a view controller's transitioning logic is called before viewDidLoad, but is the other way around from iOS 8 onwards.