簡體   English   中英

如何獲得單擊哪個注釋氣泡

[英]How to get which annotation bubble clicked

我正在使用以下代碼創建注釋氣泡按鈕:

-(MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id <MKAnnotation>) annotation
{   
    if ([annotation isKindOfClass:[MKUserLocation class]])
        return nil;

    MKPinAnnotationView *view = [mapView dequeueReusableAnnotationViewWithIdentifier:@"ParkPlaceMark"];
    if(!view)
    {
        view=[[MKPinAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:@"ParkPlaceMark"];

    }

    UIButton* rightButton = [UIButton buttonWithType:UIButtonTypeDetailDisclosure];
    [rightButton addTarget:self action:@selector(ShowDetails:)forControlEvents:UIControlEventTouchUpInside];    
    view.rightCalloutAccessoryView = rightButton;

    [view setCanShowCallout:YES];

    return [view autorelease];
}

我如何獲得單擊了哪個批注的信息,以便轉到帶有ID的詳細信息屏幕,並根據該ID獲取數據庫記錄以顯示信息。

請幫忙。

您應該實現以下委托方法:

- (void)mapView:(MKMapView *)mapView annotationView:(MKAnnotationView *)view calloutAccessoryControlTapped:(UIControl *)control
- (void)mapView:(MKMapView *)mapView annotationView:(MKAnnotationView *)view calloutAccessoryControlTapped:(UIControl *)control 

 {

   appDelegate.mallIDStr=[dict valueForKey:@"Mall_Id"];

   self.tabBarController.selectedIndex = 2;

}

在上面的代碼中,當我單擊顯示購物中心位置的任何圖釘時,我都會保存購物中心ID

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM