在嵌入式collectionView上关闭viewController平移-Swift-以编程方式

问题描述

我通过panGesture使用 UIViewControllerInteractiveTransitioningDelegate 展示和关闭ViewController:

panDown = UIPanGestureRecognizer(target: self,action: #selector(handleGesture(_:)))
    panDown.delegate = self
    view.addGestureRecognizer(panDown)

  @objc fileprivate func handleGesture(_ gesture: UIPanGestureRecognizer){
    let translate = gesture.translation(in: gesture.view)
    let percent   = translate.y / gesture.view!.bounds.size.height
    if gesture.state == .began {
        interactionController = UIPercentDrivenInteractiveTransition()
        customTransitionDelegate.interactionController = interactionController
        
        dismiss(animated: true)
    } else if gesture.state == .changed {
        interactionController?.update(percent)
    } else if gesture.state == .ended {
        let veLocity = gesture.veLocity(in: gesture.view)
        interactionController?.completionSpeed = 0.999
        if (percent > 0.5 && veLocity.y == 0) || veLocity.y > 0 {
            interactionController?.finish()
        } else {
            interactionController?.cancel()
        }
        interactionController = nil
    }
}

ViewController视图的组织方式如下:

ViewController Scheme

如果我想关闭ViewController的平移,则只能在平移实际的ViewController视图(图像中的红色区域)时执行。

我的目标是即使在collectionView到达其内容的顶部时也可以将viewController向下拖动。 直到现在,我注意到,如果我在collectionView上添加panGestureRecognizer,我实际上可以将其向下拖动,但是我无法滚动collectionView元素。

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...