I have MKMapViewimplemented with these lines of source code (my location is a blue bullet, the other is purple):
- (MKAnnotationView *)mapView:(MKMapView *)mapViewLocal viewForAnnotation:(id <MKAnnotation>)annotation {
if (annotation == mapViewLocal.userLocation) {
mapViewLocal.userLocation.title = @"Test";
[mapViewLocal setRegion:MKCoordinateRegionMakeWithDistance(mapViewLocal.userLocation.coordinate, 1000, 1000) animated:YES];
return nil;
}
MKPinAnnotationView *pinView = (MKPinAnnotationView*)[mapViewLocal dequeueReusableAnnotationViewWithIdentifier:@"Pin"];
if(pinView == nil) {
pinView = [[[MKPinAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:@"Pin"] autorelease];
pinView.pinColor = MKPinAnnotationColorPurple;
pinView.rightCalloutAccessoryView = [UIButton buttonWithType:UIButtonTypeDetailDisclosure];
pinView.animatesDrop = NO;
pinView.canShowCallout = YES;
} else {
pinView.annotation = annotation;
}
return pinView;
}
Purple pins have a disclosure button, but itβs not in my annotation. How can I set such a button?
And this is the method when I can do something on the button: pressd:
-(void)mapView:(MKMapView *)mapView annotationView:(MKAnnotationView *)view calloutAccessoryControlTapped:(UIControl *)control
How can I distinguish between my location and everyone else because I need a different treatment. Is there another delegate or do I need to make some kind of if clause?
source
share