我想使用自定義的UIPresentationController。 對於它,當我想表明新的場景我把這個代碼爲什麼不調用UIViewControllerTransitioningDelegate方法presentationControllerForPresentedViewController?
UIViewController *cv = [[...]];
cv.transitionManager=[[MyTransition alloc] init];
cv.transitioningDelegate=actionSheet.transitionManager;
cv.modalTransitionStyle = UIModalPresentationCustom;
[self presentViewController:cv animated:YES completion:^{
}];
我的過渡經理方法:
#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;
}
但該方法presentationControllerForPresentedViewController不來電!
爲什麼?
他使用UIModalPresentationCustom – litso 2015-12-22 23:41:57
@litso確實被調用。我不知道我是如何錯過的,爲什麼我的回答會被接受。作者可能會實現UIViewControllerTransitioningDelegate方法,但不符合此協議。 – Silmaril 2015-12-23 09:15:03