2014-10-22 20 views
5

Chcę użyć niestandardowego UIPresentationController. Dla niego kiedy chcę pokazać nową scenę Ja nazywam to kodDlaczego nie wywołać metody presentationControllerForPresentedViewController z UIViewControllerTransitioningDelegate?

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

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

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

}]; 

mój menedżer przejściowego metod:

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

ale metoda presentationControllerForPresentedViewController nie dzwonić!

Dlaczego?

Odpowiedz

9

To będzie wywoływana tylko wtedy, gdy obecny kontroler widoku używając stylu UIModalPresentationCustom prezentacji

+0

jest on za pomocą UIModalPresentationCustom – litso

+0

@litso rzeczywiście. Nie wiem, jak to przeoczyłem i dlaczego moja odpowiedź się wtedy przyjęła. Możliwe, że autor zaimplementował metody UIViewControllerTransitioningDelegate, ale nie dostosował się do tego protokołu. – Silmaril

6

modalPresentationStyle zamiast modalTransitionStyle jest poprawna odpowiedź :)

+1

Wow, pracowałem z niestandardowymi przejściami przez jakiś czas, a czasami sprawy robiły się dziwne i nie wiedziałem dlaczego. Istnieją modalPresentationStyle i modalTransitionStyle ... –