我在控制器上实现了这个方法来呈现:
- (id<UIViewControllerAnimatedTransitioning>)animationControllerForPresentedController:(UIViewController *)presented presentingController:(UIViewController *)presenting sourceController:(UIViewController *)source {
return [[MyAnimationController alloc] init];
}
这是我在该视图控制器上的initWithCoder:方法:
- (id)initWithCoder:(NSCoder *)aDecoder {
self = [super initWithCoder:aDecoder];
if (self) {
self.transitioningDelegate = self;
self.modalPresentationStyle = UIModalPresentationCustom;
}
return self;
}
MyAnimationController.m:
@implementation MyAnimationController
- (NSTimeInterval)transitionDuration:(id<UIViewControllerContextTransitioning>)transitionContext {
return 0.5;
}
- (void)animateTransition:(id<UIViewControllerContextTransitioning>)transitionContext {
NSLog(@"Start Transition");
[transitionContext completeTransition:YES];
}
@end
我从未收到过NSLog,也没有调用UIViewControllerTransitioningDelegate方法。谁知道为什么?