如何为两个视图实现UITapGestureRecognizer

时间:2017-06-12 09:15:19

标签: ios swift uiimageview uitapgesturerecognizer

enter image description here我想为两个Image视图实现两个UITapGestureRecognizer 一个imageView是父视图,另一个是作为这些父视图的子视图添加的 如果我向其中两个添加UITapGestureRecognizer,应用程序不会触发子视图UITapGestureRecognizer。 每个点添加了UITapGestureRecognizer,但在我的应用程序中只触发最后一个点(point16)

@IBAction func clearSubViewsFromImageMapView(_ sender: Any) {
        mapImageView.removeGestureRecognizer(tapImageGestureRecognizer)

        drawPath()
        mapImageView.subviews.forEach {
            if case _ as UIImageView = $0 {
                $0.removeFromSuperview();
                mapImageView.addSubview($0)
                $0.addGestureRecognizer(tapGestureRecognizer)

                //$0.addGestureRecognizer(tapGestureRecognizer)
            }
        }
    }

提前致谢。

0 个答案:

没有答案