[mapview addAnnotation:annotation];
addAnnotation する時に viewForAnno tationが呼び出される mapview のdelegate viewForAnnotationです。
- (MKAnnotationView*)mapView:(MK MapView*)mapView viewForAnnotation:(id <MKAnnotation>)annotation {
NSLog(@"viewForAnnotation");
// if (annotation == mapView.userLocation) return nil;
// ここでnilを返したとすると、ピンがAnnotationに使 われる
// 細かい調整は以下
MKPinAnnotationView *annotationView = [[MKPinAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:@"test"];
// [annotationView setPinColor: MKPinAnnotationColorGreen];
// [annotationView setAnimatesDrop:YES];
[annotationView setCanShowCallout:YES];// > 矢印を出すか出さないか
[annotationView setRightCalloutAccessoryView:[ UIButton buttonWithType:UIButtonTypeDet ailDisclosure]];
//UIImage *pinImage = [UIImage imageNamed:@"pin-image.png"];
//[annotationView setImage:pinImage];
annotationView.annotation = annotation;
return annotationView;
}
> を押すと calloutAccessoryControlTapped 呼び出されます。
- (void) mapView:(MKMapView*)_mapView annotationView:(MKAnnotationVi ew*)annotationView calloutAccessoryControlTapped: (UIControl*)control {
NSLog(@"タップしたときの処理 ");
// タップしたときの処理
// annotationView.annotation でどのアノテーションか判定可能
}
0 件のコメント:
コメントを投稿