0
이 코드를 사용하여 내 사용자 정의 주석보기를 만듭니다.MKAnnotationView
- (MKAnnotationView *)mapView:(MKMapView *)mV viewForAnnotation:(id <MKAnnotation>)annotation {
MKPinAnnotationView *pinAnnotation = nil;
if(annotation != myMapView.userLocation) {
static NSString *defaultPinID = @"myPin";
pinAnnotation = (MKPinAnnotationView *)[myMapView dequeueReusableAnnotationViewWithIdentifier:defaultPinID];
if (pinAnnotation == nil)
pinAnnotation = [[MKPinAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:defaultPinID];
pinAnnotation.canShowCallout = YES;
//instatiate a detail-disclosure button and set it to appear on right side of annotation
UIButton *infoButton = [UIButton buttonWithType:UIButtonTypeDetailDisclosure];
[infoButton addTarget:self
action:@selector(showRestaurantDescription)
forControlEvents:UIControlEventTouchUpInside];
pinAnnotation.rightCalloutAccessoryView = infoButton;
}
return pinAnnotation;
}
내 문제는 내 선택에 매개 변수를 보내는 방법입니다 : -showRestaurantDescription :
나는 그것을 버튼에 태그를 추가하고 처리 할 수 있다고 생각하지만, 내가 가지고 있기 때문에 내가 선택할 수있는 최선의 방법을 필요로내 식당과 배열을하고 콘크리트 핀을 누르면 현재 식당을 보여줄 필요가있다. 따라서이 경우 태그는 생각만큼 편리하지 않습니다.