私は同じ問題を駆け抜けました。その場合、彼らは注意深く考えなかったようです。クラスタ化されたMKAnnotationではなく、MKClusterAnnotationを選択する必要がありますが、そこに到達するのは簡単ではありません。
If non-nil this is the annotation view this view is clustered into.
は、だから私のMKAnnotationViewサブクラスに私がするsetSelectedメソッドをオーバーライドしてのMapViewに弱い参照して、あなたが選択する必要があります。MKAnnotationViewのプロパティがありますiOS11に
は、ドキュメントの状態としてあることcluster
と呼ばれますクラスタ1:
//You have weak reference to mapView
weak var mapView: MKMapView?
override func setSelected(_ selected: Bool, animated: Bool) {
super.setSelected(selected, animated: animated)
if #available(iOS 11.0, *) {
if selected, let cluster = cluster {
// Deselect the current annotation (Maybe this step is not required, didn't check it)
if let annotation = annotation {
mapView?.deselectAnnotation(annotation, animated: false)
}
// Select the cluster annotation
if let clusterAnnotation = cluster.annotation {
mapView?.selectAnnotation(clusterAnnotation, animated: true)
}
}
}
}