如何从UIView发送Pan Gesture触摸以滚动tableView

时间:2019-06-04 12:30:33

标签: swift uitableview uipangesturerecognizer

我在“容器”视图中有一个表格视图,页脚很高。此页脚上有平移手势识别器。平移手势控制移动容器视图的附件行为(表视图已附加到此容器)。因此,当用户平移页脚时,它实际上会(沿垂直方向)移动容器。我正在尝试做的是防止容器移动到低于屏幕底部的位置。因此,如果平移手势位于屏幕下方,则我想停止附件并仅滚动表格视图内容(就像我完全禁用应用于页脚的平移手势并像往常一样滚动内容一样)。有什么方法可以将触摸从手势手势识别器(应用于页脚)发送到tableView的内容(假设它可能是最后一行)?

 /* small note. The container actually starts right above the screen             
    bottom line. So this is why I need to prevent it's movement under the 
    screen both in .began and .changed states of a pan gesture */

    @objc func handlePan(pan: UIPanGestureRecognizer) {
        let panLocation = CGPoint(x: view.frame.width / 2, y: 
        pan.location(in: view).y)
        let velocity = pan.velocity(in: self.view)
        switch pan.state {
        case .began:
            /*here I check the direction of a pan gesture. If it goes down,  
    need to cancell attachment and instead scroll the content of a tableView*/
            if velocity.y > 0 {
               //this is where I think I need to send the touch
            }
            //some attachement and animation code here...

        case .ended: 
            //some attachement and animation code here...
        case .changed:           
            //some attachement and animation code here...

            if drawerView.frame.maxY >= (view.frame.height) {
                if velocity.y > 0 {
                    animator.removeBehavior(attachement)
                    //this is where I need to send the touch again
                } else {
                    animator.addBehavior(attachement)
                }
            }
        default:
            break
        }
    }

0 个答案:

没有答案