高德地图自定义AnnotationView没有交互效果的解决思路

在进行iOS开发的时候,出现了自定义AnnotationView导致点击AnnotationView没有点击效果。询问了官方人员后,得知要在自定义的CustomAnnotationView加入以下代码才行:

// 不加这一段无法进行交互
override func point(inside point: CGPoint, with event: UIEvent?) -> Bool {
    if self.isSelected {
        return false
    }

    if self.bounds.contains(point) {
        return true
    }

    for subView:UIView in self.subviews {
        let hitPoint = self.convert(point, to: subView)

        if subView.bounds.contains(hitPoint) {
            return true
        }
    }

    return false
}

最终问题得以解决。

你可能感兴趣的:(cocoa,macos,objective-c)