Why not call the presentationControllerForPresentedViewController method from a UIViewControllerTransitioningDelegate?

I want to use a custom UIPresentationController. To do this, when I want to show a 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 presentationControllerForPresentedViewController method does not call!

Why?

+5
source share
2 answers

It will only be called if your current presentation controller is using the presentation style UIModalPresentationCustom

+9
source

modalPresentationStyle instead of modalTransitionStyle is the correct answer :)

+6
source

Source: https://habr.com/ru/post/1205262/


All Articles