5

我正在实现自定义导航转换,并使用 UIPercentDrivenInteractiveTransition 来解决问题。

我的非交互式转换工作正常,我正在使用动画块来处理转换动画,但是一旦我添加了交互式转换,如果我取消转换,屏幕现在会变黑。

这是我跟踪手势的代码:

-(void)userDidPan:(UIScreenEdgePanGestureRecognizer *)recognizer {
        CGPoint location = [recognizer locationInView:nil];

    if (recognizer.state == UIGestureRecognizerStateBegan) {
        // We're being invoked via a gesture recognizer – we are necessarily interactive
        self.hasActiveInteraction = YES;
        self.interactiveTransition = [BXTPercentDrivenInteractiveTransition new];
        [[BXTNavigationController sharedNavigationController] popViewControllerAnimated:YES];
    }
    else if (recognizer.state == UIGestureRecognizerStateChanged) {
        CGFloat ratio = location.x / CGRectGetWidth(recognizer.view.frame);
        NSLog(@"Percentage complete: %0.2f",ratio*100);
        [self.interactiveTransition updateInteractiveTransition:ratio];
    }
    else if (recognizer.state == UIGestureRecognizerStateEnded) {
        // Depending on our state and the velocity, determine whether to cancel or complete the transition.
        CGFloat ratio = location.x / CGRectGetWidth(recognizer.view.frame);
        if (ratio > 0.50) {
            NSLog(@"Completing");
            [self.interactiveTransition finishInteractiveTransition];
        }
        else {
            NSLog(@"Canceling");
            [self.interactiveTransition cancelInteractiveTransition];
        }
    }
}

...当弹出视图控制器时,这是我的动画块的(缩写):

[UIView animateWithDuration:kBXTNavigationTimingDuration
                              delay:0
                            options:animationOption
                         animations:^{
                             toVC.view.frame = destinationFrameForPoppedView; 
                             fromVC.view.frame = CGRectOffset(fromVC.view.frame, fromVC.view.frame.size.width, 0);

                         } completion:^(BOOL finished) {
                             [darkeningView removeFromSuperview];
                             [_transition.secondaryTransitionViews enumerateObjectsUsingBlock:^(BXTTransitionView *transitionView, NSUInteger idx, BOOL *stop) {
                                 [transitionView.view removeFromSuperview];
                             }];

                             [transitionContext completeTransition:![transitionContext transitionWasCancelled]];
                         }];

任何想法为什么在使用自定义导航转换取消从左侧滑动弹出动画时屏幕变黑?

4

1 回答 1

2

解决了!我删除removeFromSuperview了动画完成块中的所有调用并解决了它(我遇到了和你一样的问题,使用几乎相同的代码,请参阅我对你的 q' 的评论)。尝试从您的代码中删除这些行:

[darkeningView removeFromSuperview];
[_transition.secondaryTransitionViews enumerateObjectsUsingBlock:^(BXTTransitionView *transitionView, NSUInteger idx, BOOL *stop) {
    [transitionView.view removeFromSuperview];
}];
于 2013-12-22T12:25:33.147 回答