Answer the question
In order to leave comments, you need to log in
ViewController not active after cancelInteractiveTransition?
I'm trying to make the transition like in the Mail app on iOS8, that is, the new letter window can be swiped down and continue working on the first screen. This transition works fine, but the problem is that when the second window is at the bottom, the first controller is not active, does not respond to clicks. To solve this problem, in the method I startInteractiveTransition:
did
[containerView insertSubview:nonModalVC.view belowSubview:modalVC.view];
: Which is not good to do, but with this approach, in the "collapsed" state, nonModalVC reacts to clicks. However, now only a black screen remains on finishInteractiveTransition. Has anyone experienced this? Or using Transitioning in principle it is impossible to achieve what I want? - (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;
}
#pragma mark - UIViewControllerInteractiveTransitioning
- (void)startInteractiveTransition:(id <UIViewControllerContextTransitioning>)transitionContext {
self.transitionContext = transitionContext;
UIViewController *modalVC = [self.transitionContext viewControllerForKey:UITransitionContextFromViewControllerKey];
UIViewController *nonModalVC = [self.transitionContext viewControllerForKey:UITransitionContextToViewControllerKey];
UIView *containerView = [self.transitionContext containerView];
[containerView insertSubview:nonModalVC.view belowSubview:modalVC.view];
[self updateInteractiveTransition:0.0];
}
#pragma mark - UIPercentDrivenInteractiveTransition
- (void)updateInteractiveTransition:(CGFloat)percentComplete{
if (percentComplete < 0) {
percentComplete = 0;
}
else if (percentComplete > 1){
percentComplete = 1;
}
UIViewController *modalVC = [self.transitionContext viewControllerForKey:UITransitionContextFromViewControllerKey];
UIViewController *nonModalVC = [self.transitionContext viewControllerForKey:UITransitionContextToViewControllerKey];
float scaleFactor = 0.9 + 0.1 * percentComplete;
float alphaVal = 0.5 + 0.5 * percentComplete;
nonModalVC.view.transform = CGAffineTransformScale(CGAffineTransformIdentity, scaleFactor, scaleFactor);
nonModalVC.view.alpha = alphaVal;
CGRect modalVCFrame = modalVC.view.frame;
modalVCFrame.origin.y = percentComplete * viewH + kModalViewYOffset;
modalVC.view.frame = modalVCFrame;
}
- (void)cancelInteractiveTransitionWithDuration:(CGFloat)duration{
UIViewController *modalVC = [self.transitionContext viewControllerForKey:UITransitionContextFromViewControllerKey];
UIViewController *nonModalVC = [self.transitionContext viewControllerForKey:UITransitionContextToViewControllerKey];
CGRect modalVCFrame = modalVC.view.frame;
modalVCFrame.origin.y = self.cancelUp ? kModalViewYOffset : viewH - kModalViewNavBarHeight;
NSLog(@"modalVCFrame.origin.y = %f", modalVCFrame.origin.y);
CGAffineTransform transformVal = self.cancelUp ?
CGAffineTransformMakeScale(kNonModalViewMinScale, kNonModalViewMinScale)
: CGAffineTransformIdentity;
CGFloat alphaVal = self.cancelUp ? 0.5 : 1.0;
[UIView animateWithDuration:duration animations:^{
modalVC.view.frame = modalVCFrame;
nonModalVC.view.transform = transformVal;
nonModalVC.view.alpha = alphaVal;
} completion:^(BOOL finished) {
[self cancelInteractiveTransition];
}];
reversed = NO;
}
- (void)finishInteractiveTransitionWithDuration:(CGFloat)duration{
UIViewController *modalVC = [self.transitionContext viewControllerForKey:UITransitionContextFromViewControllerKey];
UIViewController *nonModalVC = [self.transitionContext viewControllerForKey:UITransitionContextToViewControllerKey];
CGRect modalVCFrame = modalVC.view.frame;
modalVCFrame.origin.y = viewH ; //+ kModalViewNavBarHeight;
[UIView animateWithDuration:duration animations:^{
modalVC.view.frame = modalVCFrame;
nonModalVC.view.transform = CGAffineTransformIdentity;
nonModalVC.view.alpha = 1.0;
} completion:^(BOOL finished) {
[modalVC.view removeFromSuperview];
[self.transitionContext completeTransition:YES];
self.transitionContext = nil;
[self finishInteractiveTransition];
}];
reversed = NO;
}
Answer the question
In order to leave comments, you need to log in
Solved a problem. The first is to not add anything to the containerView during dismissing. Second - I made a UIView category and rewrote the method hitTest:withEvent:
so that it "passes" clicks through itself when the modal window is "minimized".
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question