메서드 이름이 잘못되었습니다. 그것은 자본 V
와 mapView
해야한다 :
- (MKAnnotationView *)mapView:(MKMapView *)sender
viewForAnnotation:(id <MKAnnotation>)annotation
오브젝티브 C는 대소 문자를 구분합니다.
여전히 메서드가 호출되지 않으면지도 뷰의 delegate
이 설정되지 않은 것입니다. 코드에서 self
으로 설정하거나 인터페이스 작성기에서 파일 소유자에게 대리인을 첨부하십시오.
주석을 추가하기 전에 title
을 설정해야합니다. 그렇지 않으면 설명 선이 계속 표시되지 않습니다.
위의 변경 사항은 액세서리 버튼이 나타나지 않도록 수정해야합니다.
다른 어떤 관련이없는 제안 ... viewForAnnotation
에서
, 당신은 dequeueReusableAnnotationViewWithIdentifier
를 호출하여 주석보기 재사용을 지원해야한다 : 프로젝트 ARC를 사용하는 경우
는
- (MKAnnotationView *)mapView:(MKMapView *)sender viewForAnnotation:(id <MKAnnotation>)annotation
{
static NSString *reuseId = @"StandardPin";
MKPinAnnotationView *aView = (MKPinAnnotationView *)[sender
dequeueReusableAnnotationViewWithIdentifier:reuseId];
if (aView == nil)
{
aView = [[[MKPinAnnotationView alloc] initWithAnnotation:annotation
reuseIdentifier:reuseId] autorelease];
aView.rightCalloutAccessoryView = [UIButton buttonWithType:UIButtonTypeDetailDisclosure];
aView.canShowCallout = YES;
}
aView.annotation = annotation;
return aView;
}
의 autorelease
를 제거합니다. 그런데
는, 구현, 액세서리 버튼을 눌러
calloutAccessoryControlTapped
대리자 메서드를 응답하기 :
- (void)mapView:(MKMapView *)mapView annotationView:(MKAnnotationView *)view
calloutAccessoryControlTapped:(UIControl *)control
{
NSLog(@"accessory button tapped for annotation %@", view.annotation);
}
당신이 시도 무엇을 당신이 얻을 정확히 어떤 오류 또는 문제 보여줄 수 있습니까? – Anna