I am trying to change the callout view of a pin. I use a .xib which contains a label and an image and it should appear when the user taps an annotation.
I use this code:
func mapView(mapView: MKMapView!, didSelectAnnotationView annotation: MKAnnotationView!) -> UIView!
{
println("delegate")
let pin = annotation as! CustomPointAnnotation
if let infoView = UIView.viewFromNibName("AnnInfoView") as? AnnInfoView {
infoView.nameLabel.text = pin.title
if let photo = pin.imageName {
infoView.placePhoto.image = UIImage(named: photo)
} else {
infoView.placePhoto.image = UIImage(named: "generic")
}
return infoView
} else {
return nil
}
}
The problem is that I get this error:
Objective-C method 'mapView:didSelectAnnotationView:' provided by method 'mapView(:didSelectAnnotationView:)' conflicts with optional requirement method 'mapView(:didSelectAnnotationView:)' in protocol 'MKMapViewDelegate'
and can't find a solution.
I use a this Objective-C library: https://github.com/RVLVR/REVClusterMap which clusters the annotations.
I have found in a file of this library this method:
- (void)mapView:(MKMapView *)mapView didSelectAnnotationView:(MKAnnotationView *)view
{
if( [delegate respondsToSelector:@selector(mapView:didSelectAnnotationView:)] )
{
[delegate mapView:mapView didSelectAnnotationView:view];
}
}
but even if I comment it the error still won't disappear :(
What am I doing wrong?
Thank you!
void
and you have aView!
. So it's not the same method. – Stefan Salatic