2014-10-22 4 views
5

Я хочу использовать пользовательский UIPresentationController. Для этого, когда я хочу показать новую сцену, которую я называю этот кодПочему не вызывать метод presentationControllerForPresentedViewController из UIViewControllerTransitioningDelegate?

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 не вызывает!

Почему?

ответ

9

Он будет называться только если присутствует контроллер вид, используя стиль UIModalPresentationCustom презентации

+0

он использует UIModalPresentationCustom – litso

+0

@litso действительно. Я не знаю, как я это пропустил, и почему мой ответ был принят тогда. Возможно, автор реализовал методы UIViewControllerTransitioningDelegate, но не соответствовал этому протоколу. – Silmaril

6

modalPresentationStyle вместо modalTransitionStyle является правильным ответом :)

+1

Вау, я некоторое время работал с пользовательскими переходами, а иногда все странно, и я не знал почему. Существуют модальныеPresentationStyle и modalTransitionStyle ... –

Смежные вопросы