2

사실 내 MKMapView 내 주석을 표시하는 응용 프로그램에서 뭔가를 개발하고 있으며 해당 주석을 클릭 할 수 있어야하고 매개 변수를 메서드에 전달해야합니다.
문제는 공개 버튼을 탭할 때 매개 변수를 다음 함수로 전달하는 방법입니다.
주석 서식의 경우 공개 단추를 표시하기 위해 - (MKAnnotationView *)mapView:(MKMapView *)aMapView viewForAnnotation:(id <MKAnnotation>)annotation 메서드를 사용합니다. 하지만 문제는 순간에 표시되는 Annotation 개체에서 값을 가져 오는 방법입니다.MKAnnotationView 및 다른 함수에 데이터 전달

Annotation (단지 관련 부분)에 대한 나의 코드 :

@synthesize coordinate, id, title, subtitle; 

+ (id)annotationWithCoordinate:(CLLocationCoordinate2D)coordinate { 
    return [[[[self class] alloc] initWithCoordinate:coordinate] autorelease]; 
} 

- (id)initWithCoordinate:(CLLocationCoordinate2D)coordinate { 
    self = [super init]; 

    if(nil != self) { 
     self.coordinate = coordinate; 
    } 

    return self; 
} 

그리고 공개 버튼을 터치 할 때 방법 - (void)displayInfo:(NSNumber *) anId;anId PARAM로 Annotation.id 넘겨 호출해야합니다.

공시 버튼은 코드 생성 : 그래서

UIButton *disclosureButton = [UIButton buttonWithType:UIButtonTypeDetailDisclosure]; 

    dropPin.rightCalloutAccessoryView = disclosureButton; 
    dropPin.animatesDrop = YES; 
    dropPin.canShowCallout = YES; 

- 질문 :
가 어떻게 함수에이 PARAM을 전달하거나 클릭 한 Annotationid을 읽을 수 있습니까?

UButton (그러나 ID 전달 방법) 또는 - (void)mapView:(MKMapView *)mapView annotationView:(MKAnnotationView *)view calloutAccessoryControlTapped:(UIControl *)control (다시 - ID 전달 방법) 중 하나를 사용하여 disclosureButton의 탭 처리를 수행 할 수 있다고 생각했습니다.

내가 무슨 뜻인지 아셔서 당신의 답변에 미리 감사드립니다. :) 주석 뷰를 통해 볼 수 있습니다 calloutAccessoryControlTapped에서

+0

또한, 어노테이션 클래스에서, 보이는? 최선을 다해 이름을 추천하고, 엔 니이 퀼러가 대답 할 때 필요하지 않을 수도 있습니다. – Anna

+0

그건 좋은 생각입니다 ;-), 맞습니다. 도와 주셔서 감사합니다 :). – thedom

답변

4

: 당신은 "ID"라는 이름의 속성을 선언 한 것 같은

MKAnnotation *annotation = view.annotation; 
+0

정말 도움이되었습니다! 아주 많이 고마워! – thedom

+0

대단히 환영합니다! – ennuikiller