I have created a custom MKPinAnnotationView for all my map pins, but I'm having a problem customising the user location pin. If I create a custom pin for it, then I lose the blue pulsating dot and it is replaced with a pin, which I don't want. So I return nil in the viewForAnnotation method:
- (MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id<MKAnnotation>)annotation
{
if(annotation == self.mapView.userLocation)
{
// show the blue dot for user's GPS location
return nil;
}
... code for custom annotation pins goes here
}
However, I do want it to invoke a custom callout view when I tap on it. I've tried adding a subview when the blue dot has been selected:
- (void)mapView:(MKMapView *)mapView didSelectAnnotationView:(MKAnnotationView *)view
{
if(view == [self.mapView viewForAnnotation:self.mapView.userLocation])
{
MKAnnotationView *userLocationView = [self.mapView viewForAnnotation:self.mapView.userLocation];
userLocationCalloutView = [[MyAnnotationCalloutView alloc] initWithFrame:CGRectMake(-113, -58, 247, 59)];
[userLocationCalloutView.rightAccessoryButton addTarget:self action:@selector(pinButtonTapped) forControlEvents:UIControlEventTouchDown];
[userLocationView addSubview:userLocationCalloutView];
}
}
But the problem with this is that the callout accessory button is outside of the hit area, and I cannot add a hitTest:withEvent because the blue dot annotation view is private... Any ideas?