I have the following code:
func mapView(_ mapView: MKMapView, didSelect view: MKAnnotationView) {
if view.annotation is MKUserLocation {
view.canShowCallout = false
} else {
self.locationInfoContainerView.isHidden = false
}
}
I was hoping this would do the following: Show the container view when I tap annotation different than the user location.
What this code does, is shows the container view when I tap the USERLOCATION and not when I click annotation of other points on the map (So it does the exact opposite), I tried reversing the code like this:
func mapView(_ mapView: MKMapView, didSelect view: MKAnnotationView) {
if view.annotation is MKUserLocation {
self.locationInfoContainerView.isHidden = false
} else {
view.canShowCallout = false
}
}
But this yields the same result. Can some shed some clarity on this and help me with programming the desired behavior? I.E: Showing the container view WHEN tapped on map annotation DIFFERENT than the user location on the map.
Hope this is clear enough, thanks guys.
The solution was:
func mapView(_ mapView: MKMapView, viewFor annotation: MKAnnotation) -> MKAnnotationView? {
if annotation is MKUserLocation {
return nil
}
:
: