2

사용자 지정 전환을 사용하는보기 컨트롤러가 있는데 제대로 작동합니다. UIModalPresentationCustom을 사용할 때 프리젠 테이션 뷰 컨트롤러는 제거되지 않고 투명도를 가진 새 뷰 컨트롤러를 배치한다는 점을 이용합니다.UIViewController 사용자 지정 전환 및 상태 복원

그러나 이것을 상태 복원과 함께 사용하면 표시 컨트롤러 IS가 제거됩니다. 뷰 컨트롤러가 애니메이션없이 표시되기 때문에 사용자 정의 트랜지션 코드가 호출되지 않는 것 같습니다. 보기 컨트롤러가 애니메이션으로 표시되지 않는 경우에도 사용자 지정 전환을 활성화 할 수있는 방법이 있습니까?

- (id<UIViewControllerAnimatedTransitioning>)animationControllerForPresentedController:(UIViewController *)presented 
                    presentingController:(UIViewController *)presenting 
                     sourceController:(UIViewController *)source 
{ 
    // never called if we aren't animating 
    return self; 
} 

- (id<UIViewControllerAnimatedTransitioning>)animationControllerForDismissedController:(UIViewController *)dismissed 
{ 
    return self; 
} 

- (NSTimeInterval)transitionDuration:(id <UIViewControllerContextTransitioning>)transitionContext 
{ 
    return 0.25; 
} 

- (void)animateTransition:(id <UIViewControllerContextTransitioning>)transitionContext 
{ 
    UIViewController *fromViewController = [transitionContext viewControllerForKey:UITransitionContextFromViewControllerKey]; 
    UIViewController *toViewController = [transitionContext viewControllerForKey:UITransitionContextToViewControllerKey]; 

    if (toViewController == self) { 
     [transitionContext.containerView addSubview:fromViewController.view]; 
     [transitionContext.containerView addSubview:toViewController.view]; 

     self.maskView.alpha = 0.0f; 
     self.menuView.frame = CGRectMake(0, self.view.bounds.size.height, self.view.bounds.size.width, 286.0f); 

     [UIView animateWithDuration:[self transitionDuration:transitionContext] animations:^{ 
      fromViewController.view.tintAdjustmentMode = UIViewTintAdjustmentModeDimmed; 

      [self.menuView updateFrame:^(CGRect *frame) { 
       frame->origin.y = self.view.bounds.size.height - frame->size.height; 
      }]; 

      self.maskView.alpha = 0.75f; 
     } completion:^(BOOL finished) { 
      self.maskView.userInteractionEnabled = YES; 
      [transitionContext completeTransition:YES]; 
     }]; 
    } else { 
     [transitionContext.containerView addSubview:toViewController.view]; 
     [transitionContext.containerView addSubview:fromViewController.view]; 

     self.maskView.userInteractionEnabled = NO; 

     [UIView animateWithDuration:[self transitionDuration:transitionContext] animations:^{ 
      toViewController.view.tintAdjustmentMode = UIViewTintAdjustmentModeAutomatic; 

      [self.menuView updateFrame:^(CGRect *frame) { 
       frame->origin.y = self.view.bounds.size.height; 
      }]; 

      self.maskView.alpha = 0.0f; 
     } completion:^(BOOL b){ 
      [transitionContext completeTransition:YES]; 

      [self.menuView updateFrame:^(CGRect *frame) { 
       frame->origin.y = self.view.bounds.size.height - frame->size.height; 
      }]; 
     }]; 
    } 
} 

답변

0

나는 당신의 presentingVC이 상태 복원에 대한 계층 구조에서 제거 할 수있는 방법을 볼 수 없습니다,하지만 것이 도움이된다하면 앱 위임에 다음을 넣어 :

- (UIViewController*)application:(UIApplication *)application viewControllerWithRestorationIdentifierPath:(NSArray *)identifierComponents coder:(NSCoder *)coder { 
    NSLog(@"Application restore state = %@", [identifierComponents componentsJoinedByString:@"."]); 

    return nil; 
} 

당신이 따를 수있는이 방법을 사용자 지정 상태 복원 클래스를 구현하지 않고 Storyboard를 사용하여 상태 복원 논리를 만듭니다. 이것은 생각을위한 음식을 줄 수 있습니다.