简体   繁体   English

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

[英]Why don't call method presentationControllerForPresentedViewController of UIViewControllerTransitioningDelegate?

I want use custom UIPresentationController. 我想使用自定义UIPresentationController。 For it when I want show new scene I call this code 对于它,当我想要显示新场景时,我称之为代码

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

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

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

}];

my transition manager has methods: 我的过渡经理有方法:

#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;
}

but the method presentationControllerForPresentedViewController doesn't call! 但方法presentationControllerForPresentedViewController不调用!

Why? 为什么?

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

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM