質問

実際、私はアプリで何かを開発しています。 MKMapView また、これらの注釈はクリック可能で、PARAMをメソッドに渡す必要があります。
問題は、開示ボタンをタップするときにパラメーターを次の関数に渡す方法です。
注釈のフォーマットのために使用します - (MKAnnotationView *)mapView:(MKMapView *)aMapView viewForAnnotation:(id <MKAnnotation>)annotation 開示ボタンを表示する方法。しかし、問題は、値から値を取り除く方法です Annotation 現時点で表示されているオブジェクト?

の私のコード 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; 引き渡して呼び出す必要があります Annotation.id として anId パラメーション。

開示ボタンは、そのコードで生成されます。

   UIButton *disclosureButton = [UIButton buttonWithType:UIButtonTypeDetailDisclosure];

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

だから - 質問:
どうすればそのパラメーションを関数に渡すか、読むことができますか id クリックしたもの Annotation?

uibuttonのセレクター(しかし - IDを渡す方法)または - (void)mapView:(MKMapView *)mapView annotationView:(MKAnnotationView *)view calloutAccessoryControlTapped:(UIControl *)control (繰り返します - IDに合格する方法は?)。

私が何を意味するかを知っていることを願っています、そしてあなたの答えに事前に非常に感謝します! :)

役に立ちましたか?

解決

CalloutAccessoryControltappedでは、アノテーションはビューで利用できます。

MKAnnotation *annotation = view.annotation;
ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top