允许scrollview将手势传递给子视图的正确方法是什么?
答案 0 :(得分: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
}
}
}