사용자 지정 전환을 사용하는보기 컨트롤러가 있는데 제대로 작동합니다. 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;
}];
}];
}
}