I found some strange behavior with long click on MKPointAnnotation
.
I create my pin like this:
MKPointAnnotation *activeTRPoint = [[MKPointAnnotation alloc] init];
CLLocation *coord = [[CLLocation alloc] initWithLatitude:latitude longitude:longitude];
activeTRPoint.coordinate = coord.coordinate;
activeTRPoint.title = @"Title";
activeTRPoint.subtitle = @"subtitle";
//Added tag
[map addAnnotation:activeTRPoint];
[[map viewForAnnotation:activeTRPoint] setTag:1];
UIImage *im = [UIImage imageNamed:@"pin_icon.png"];
[[map viewForAnnotation:activeTRPoint] setImage:im];
So when I long click on the pin it changes to red pin (default). Do you have any idea why this happens?
UPDATE: Added viewForAnnotation method for further investigation
- (MKAnnotationView *) mapView:(MKMapView *)mapView1 viewForAnnotation:(id <MKAnnotation>) annotation
{
if(annotation != map.userLocation){
// This is not the users location indicator (the blue dot)
MKAnnotationView *view = [map dequeueReusableAnnotationViewWithIdentifier:@"myAnnotationIdentifier"];
BOOL isCustomPin = [subtitles containsObject:((MKPointAnnotation*)annotation).subtitle];
if (!view && isCustomPin == NO) {
// Creating a new annotation view, in this case it still looks like a pin
MKPinAnnotationView *annView = [[MKPinAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:@"myAnnotationIdentifier"];
annView.pinColor = MKPinAnnotationColorGreen;
view = annView;
view.canShowCallout = YES; // So that the callout can appear
UIButton *btnViewVenue = [UIButton buttonWithType:UIButtonTypeDetailDisclosure];
[btnViewVenue addTarget:self action:@selector(pinTouched:) forControlEvents:UIControlEventTouchUpInside];
view.rightCalloutAccessoryView = btnViewVenue;
view.enabled = YES;
view.canShowCallout = YES;
view.multipleTouchEnabled = NO;
}else{
UIImage *im = [UIImage imageNamed:@"pin_icon.png"];
[view setImage:im];
}
return view;
}else{
mapView1.userLocation.title = [Lang get:@"USER_CURRENT_LOCATION"];
mapView1.userLocation.subtitle = @"";
[mapView1 setTag:999];
return nil;
}
}