2

我创建了自定义推送/弹出交互式转换,但我不明白如何同时处理这种转换和表格视图滚动。

为了处理自定义弹出动画,我添加了平移手势

let pan = UIPanGestureRecognizer(
                target: self,
                action: #selector(didPan))
pan.delegate = self
view.addGestureRecognizer(pan)

接下来我处理这个锅

if recognizer.state == .began {
    animator.interactive = true
    navigationController!.popViewController(animated: true)
}

animator.handlePan(recognizer: recognizer)

然后内部动画师符合UIPercentDrivenInteractiveTransitionUIViewControllerAnimatedTransitioning我做变换动画。我尝试通过平移手势从 VC_2 弹出导航到 VC_1。

问题是添加平移手势表视图后不滚动。我认为这是因为 2 个手势识别器(我自己的和 UIKit 表格视图的识别器)。实际上,当表格向上滚动时,我希望我自己的平底锅以交互方式弹出我的 VC_2。

唯一的想法是

func gestureRecognizer(
        _ gestureRecognizer: UIGestureRecognizer,
        shouldRecognizeSimultaneouslyWith otherGestureRecognizer: UIGestureRecognizer) -> Bool {
    return tableView.contentOffset.y <= 0
}

但是在弹出表视图偏移量发生了奇怪的变化:我的意思是当平移手势移动时表滚动太多(移动 20 像素,偏移量更改为 500 像素)。

处理这个问题的最佳方法是什么?您可以在 Google 的 Inbox 应用程序中看到这样的动画 - 从电子邮件弹出到列表。

4

0 回答 0