为什么不调用UIViewControllerTransitioningDelegate的方法presentationControllerForPresentedViewController?

Vit*_*Vit 5 iphone objective-c ios ios8 ios8-extension

我想使用自定义UIPresentationController.对于它,当我想要显示新场景时,我称之为代码

UIViewController *cv = [[...]];

cv.transitionManager=[[MyTransition alloc] init];
cv.transitioningDelegate=actionSheet.transitionManager;
cv.modalTransitionStyle = UIModalPresentationCustom;

[self presentViewController:cv animated:YES completion:^{

}];
Run Code Online (Sandbox Code Playgroud)

我的过渡经理有方法:

#pragma mark - UIViewControllerTransitioningDelegate

- (id <UIViewControllerAnimatedTransitioning>)animationControllerForPresentedController:(UIViewController *)presented presentingController:(UIViewController *)presenting sourceController:(UIViewController *)source{
    return self;
}

- (id <UIViewControllerAnimatedTransitioning>)animationControllerForDismissedController:(UIViewController *)dismissed{
    return self;
}

- (id <UIViewControllerInteractiveTransitioning>)interactionControllerForPresentation:(id <UIViewControllerAnimatedTransitioning>)animator{
    return  nil;
}

- (id <UIViewControllerInteractiveTransitioning>)interactionControllerForDismissal:(id <UIViewControllerAnimatedTransitioning>)animator{
    return self;
}


- (UIPresentationController *)presentationControllerForPresentedViewController:(UIViewController *)presented presentingViewController:(UIViewController *)presenting sourceViewController:(UIViewController *)source {
    MyPresentationController *presentationController = [[MyPresentationController alloc] initWithPresentedViewController:presented presentingViewController:presenting];
    return presentationController;
}
Run Code Online (Sandbox Code Playgroud)

但方法presentationControllerForPresentedViewController不调用!

为什么?

Sil*_*ril 10

仅当您使用UIModalPresentationCustom演示文稿样式呈现视图控制器时才会调用它


mie*_*tus 9

modalPresentationStyle而不是modalTransitionStyle一个正确的答案:)