Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

iOS 13.3系统 底部弹出后侧滑返回动画异常 #16

Open
happying opened this issue Mar 8, 2020 · 7 comments
Open

iOS 13.3系统 底部弹出后侧滑返回动画异常 #16

happying opened this issue Mar 8, 2020 · 7 comments

Comments

@happying
Copy link

happying commented Mar 8, 2020

iOS 13.3系统,利用
+ (instancetype)animatorWithSwipeType:(TLSwipeType)swipeType pushDirection:(TLDirection)pushDirection popDirection:(TLDirection)popDirection;
- (void)pushViewController:(UIViewController *)viewController animator:(id<TLAnimatorProtocol>)animator;
进行上下移动动画弹出的controller,在侧滑返回时,动画会出现异常,与低版本相比,会缺乏一个渐进过程,滑动非常小的幅度,动画幅度也会非常大

@happying
Copy link
Author

happying commented Mar 8, 2020

更新一下刚刚断点得到的信息,问题出现在TLPercentDrivenInteractiveTransition.m里面

  • (CGFloat)percentForGesture:(UIPanGestureRecognizer *)gesture中关于if ([gesture isMemberOfClass: [UIScreenEdgePanGestureRecognizer class]]) 这一判断
    在高版本系统中,该判断将为false并最终得出一个错误的present,导致动画异常

@LoongerTao
Copy link
Owner

在iOS13中UIScreenEdgePanGestureRecognizer手势失效了,我自己加的一个pan手势。可能存在问题。

@LoongerTao
Copy link
Owner

最近比较忙没时间维护,您可以自己修正一下。 (如果方便,修正后可以贡献下您的代码)

@happying
Copy link
Author

最近比较忙没时间维护,您可以自己修正一下。 (如果方便,修正后可以贡献下您的代码)

抱歉,最近刚好在发版本,所以做的处理很简单,就是更改了一下判断方式,将新增的手势类别加进了判断条件中,因为只用到了相关的push动画更改,目前来看是测试正常的,但并没有进行全量的测试。

@LoongerTao
Copy link
Owner

您好!

  • 问题已经找到了,在iOS 13中UIScreenEdgePanGestureRecognizer手势失效,所以我自定义了一个TLScreenEdgePanGestureRecognizer 作为替代,在下面方法中遗漏了一个兼容判断。
  • 👇是修正后的代码,本次修改我会更新到githup,但是暂时不会进行版本迭代。
// 返回交互过渡完成的百分比。
- (CGFloat)percentForGesture:(UIPanGestureRecognizer *)gesture
{
    // 因为视图控制器将作为动画的一部分在屏幕上或从屏幕上滑动,因此我们希望将计算建立在不移动视图的坐标空间:transitionContext.containerView。
    UIView *containerView = self.transitionContext.containerView;
    
    CGPoint locationInSourceView = [gesture locationInView:containerView];
    CGFloat width = CGRectGetWidth(containerView.bounds);
    CGFloat height = CGRectGetHeight(containerView.bounds);
    
    CGFloat percent = 0.f;
    
//================== 修改开始 ====================
    // 增加对TLScreenEdgePanGestureRecognizer的兼容
    if ([gesture isMemberOfClass: [UIScreenEdgePanGestureRecognizer class]] ||
        [gesture isMemberOfClass: NSClassFromString(@"TLScreenEdgePanGestureRecognizer")])
//================== 修改结束 ====================
    {
        if (self.edge == UIRectEdgeRight) {
            percent = (width - locationInSourceView.x) / width;
            
        } else {
            // 垂直方向的转场以左侧滑作为依据
            percent = locationInSourceView.x / width;
        }
        
    }else { // 用户自定义收拾
        
        if (self.edge == UIRectEdgeRight) {
            percent = (width - locationInSourceView.x) / width;
            
        } else if (self.edge == UIRectEdgeLeft) {
            // 垂直方向的转场以左侧滑作为依据
            percent = locationInSourceView.x / width;
    
        } else if (self.edge == UIRectEdgeBottom) {
            percent = (height - locationInSourceView.y) / height;
    
        }else if (self.edge == UIRectEdgeTop) {
            percent = locationInSourceView.y / height;
        }
    }
    
    if (_speedOfPercent >= 0.2) {
        percent *= _speedOfPercent;
    }
    
    return percent;
}

@LoongerTao
Copy link
Owner

您可以用您的代码测试一下,因为时间紧迫,我就没有全面测试(但按照我的代码逻辑,因该是解决了的)

LoongerTao pushed a commit that referenced this issue Mar 16, 2020
@happying
Copy link
Author

您可以用您的代码测试一下,因为时间紧迫,我就没有全面测试(但按照我的代码逻辑,因该是解决了的)

辛苦作者大大,这个和我的解决方法完全一致,目前没有发现有额外的问题发生,我们可以对此进行持续跟进

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants