2016-06-14 3 views
1

UIViewControllerTransitioningDelegate, UIViewControllerAnimatedTransitioningUIPresentationController을 사용하여 모달로 제공된보기 컨트롤러에 대한 사용자 지정 전환을 만들려고합니다. 내 제시 뷰 컨트롤러에서presentationTransitionWillBegin에서 animateAlongsideTransition을 사용하는 경우

나는 UIViewControllerTransitioningDelegate를 구현하고 다음과 같은 방법이 있습니다

-(id<UIViewControllerAnimatedTransitioning>)animationControllerForPresentedController:(UIViewController *)presented 
                   presentingController:(UIViewController *)presenting 
                    sourceController:(UIViewController *)source { 

    return [[MyAnimationController alloc] initWithAnimationType:MyAnimationTypePresent]; 
} 

- (id<UIViewControllerAnimatedTransitioning>)animationControllerForDismissedController:(UIViewController *)dismissed { 
    return [[MyAnimationController alloc] initWithAnimationType:MyAnimationTypeDismiss]; 
} 

- (UIPresentationController *)presentationControllerForPresentedViewController:(UIViewController *)presented 
                presentingViewController:(UIViewController *)presenting 
                 sourceViewController:(UIViewController *)source { 

    return [[MyPresentationController alloc] initWithPresentedViewController:presented presentingViewController:presenting]; 
} 

지금 UIPresentationController 내 하위 클래스에서 내가 제시 한 뷰 컨트롤러 아래 디밍보기를 추가하고 함께 그것을 퇴색 할

을 외관 변화.

- (void)presentationTransitionWillBegin { 
    self.dimmingView.alpha = 0.0f; 
    [self.containerView insertSubview:self.dimmingView atIndex:0]; 
    [self.dimmingView autoPinEdgesToSuperviewEdges]; 

    [self.presentedViewController.transitionCoordinator animateAlongsideTransition:^(id<UIViewControllerTransitionCoordinatorContext> _Nonnull context) { 
     self.dimmingView.alpha = 1.0f; 
    } 
                    completion:nil]; 
} 

- (void)dismissalTransitionWillBegin { 

    [self.presentedViewController.transitionCoordinator animateAlongsideTransition:^(id<UIViewControllerTransitionCoordinatorContext> _Nonnull context) { 
     self.dimmingView.alpha = 0.0f; 
    } 
                    completion:^(id<UIViewControllerTransitionCoordinatorContext> _Nonnull context) { 
                     [self.dimmingView removeFromSuperview];                 }]; 
} 

재미있는 - 아주 실망 - 일 내 발표 뷰 컨트롤러 작업에 대한 프리젠 테이션 및 해고 애니메이션이 예상대로와 MyAnimationController에 구현 된 것입니다. 내 디밍보기의 페이드 인/아웃에 대해서는 제공된보기 컨트롤러를 닫을 때만 작동합니다. 프리젠 테이션을 할 때 페이드 인은 전환과 함께 움직이지 않지만 고정 된 시간 만 사용합니다. 나는 애플의 문서와 튜토리얼에 따라 모든 것을 구현했음을 확신하지만 어떤 이유인지 그것은 예상대로 작동하지 않을 것이다. 어떤 문제가 여기에 있을지에 대한 제안?

답변

1

내가 사용하려는 믿는 presentingViewControllertransitionCoordinator 프리젠 테이션에, 그리고 presentedViewConrollertransitionCoordinator 해고에. 그렇기 때문에 현재 해고로 인해 발표가 아닌 해고로 진행되는 것입니다.