Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why don't call method presentationControllerForPresentedViewController of UIViewControllerTransitioningDelegate?

I want use custom 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!

Why?

like image 873
Vit Avatar asked Oct 22 '14 09:10

Vit


2 Answers

It will be called only if your present a view controller using the UIModalPresentationCustom presentation style

like image 88
Silmaril Avatar answered Oct 17 '22 01:10

Silmaril


modalPresentationStyle instead of modalTransitionStyle is a correct answer :)

like image 28
Michal Zaborowski Avatar answered Oct 17 '22 02:10

Michal Zaborowski