0

允许滚动视图将手势传递给子视图的正确方法是什么?

4

1 回答 1

0

您应该像这样向 ScrollView 添加手势识别器:

        let tapGestureRecognizer = UITapGestureRecognizer(target: self, action: "handleTap:")
        scrollView.addGestureRecognizer(tapGestureRecognizer)

然后像这样处理水龙头:

func handleTap(tap: UITapGestureRecognizer)  {

        let location = tap.locationInView(tap.view)

        for i in 0..<scrollView.subviews.count{
            let subViewTapped = scrollView.subviews[i]
            if CGRectContainsPoint(subViewTapped.frame, location) {

        print("tapped subview at index\(i)")
                // do your stuff here

            }
        }

    }
于 2016-08-23T12:07:06.827 回答