gpt4 book ai didi

iphone - UIPercentDrivenInteractiveTransition cancelTransition 将屏幕变黑

转载 作者:行者123 更新时间:2023-12-03 19:17:52 26 4
gpt4 key购买 nike

我正在实现自定义导航转换,并使用 UIPercentDrivenInteractiveTransition 来实现这一点。

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

这是我跟踪手势的代码:

-(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];
}
}
}

...这是弹出 View Controller 时我的动画 block 的(缩写)外观:

[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]];
}];

您知道为什么在使用自定义导航过渡取消从左滑动弹出动画时屏幕会变黑吗?

最佳答案

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

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

关于iphone - UIPercentDrivenInteractiveTransition cancelTransition 将屏幕变黑,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19287800/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com