问题描述
我通过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视图(图像中的红色区域)时执行。
我的目标是即使在collectionView到达其内容的顶部时也可以将viewController向下拖动。 直到现在,我注意到,如果我在collectionView上添加panGestureRecognizer,我实际上可以将其向下拖动,但是我无法滚动collectionView元素。
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)