我MKPointAnnotation應該與此代碼進行定製:爲什麼我的MKPointAnnotation不是自定義的?
-(MKPointAnnotation*)setAnnotation: (NSString*) title atLocation:(CLLocationCoordinate2D)Location withImage:(UIImage*) LocationImage{
Pin = [[MKPointAnnotation alloc] init];
Pin.title = title;
[Pin setCoordinate:Location];
[self mapView:mapView viewForAnnotation:Pin].annotation = Pin;
return Pin;
}
-(MKAnnotationView *)mapView: (MKMapView *)mapView viewForAnnotation: (id<MKAnnotation>) annotation{
MKPinAnnotationView* pinView = (MKPinAnnotationView*)[mapView dequeueReusableAnnotationViewWithIdentifier:@"CustomPinAnnotationView"];
if(!pinView){
pinView = [[MKPinAnnotationView alloc]initWithAnnotation:annotation reuseIdentifier:@"CustomPinAnnotationView"];
pinView.animatesDrop = YES;
pinView.canShowCallout = YES;
pinView.enabled = YES;
UIButton *PicButton = [UIButton buttonWithType:UIButtonTypeDetailDisclosure];
[PicButton addTarget:self action:@selector(showLocationPicture) forControlEvents:UIControlEventTouchUpInside];\
pinView.rightCalloutAccessoryView = PicButton;
}
else{
pinView.annotation = annotation;
}
return pinView;
}
然而,出於某種原因,該引腳仍處於違約,誰能幫助我在這裏? 謝謝
但是,如何調整註釋的設置呢?因爲現在我使用像pinView.rightCalloutAccessoryView = PicButton;但是這也行不通 – 2013-05-12 12:38:02
@BlackMagic查看我的修訂答案和更完整的代碼示例。 – Rob 2013-05-12 12:39:17
非常感謝,這正是我所需要的。 – 2013-05-12 12:55:37