2013-10-09 43 views

回答

1

嘗試添加rightCalloutAccessoryView

- (MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id <MKAnnotation>)annotation 
{ 
    static NSString * identifier = @ "pinId" ; 

    MKAnnotationView *pin = [mapView dequeueReusableAnnotationViewWithIdentifier:identifier ]; 
    if (!pin &&(annotation != mapView.userLocation)) 
    { 
     pin = [ [ MKAnnotationView alloc ] initWithAnnotation:annotation reuseIdentifier:identifier ]; 
     pin.image = [UIImage imageNamed: @"g_pin.png" ]; 
     pin.canShowCallout = YES; 

      pin.rightCalloutAccessoryView = [UIButton buttonWithType:UIButtonTypeDetailDisclosure]; 
    } 
    pin.annotation = annotation; 

    return pin; 

} 

您將獲得右上角的按鈕像

enter image description here

輕敲這個按鈕這種方法將被稱爲

- (void)mapView:(MKMapView *)_mapView annotationView:(MKAnnotationView *)view calloutAccessoryControlTapped:(UIControl *)control 
{ 
    NSLog(@"Pin Tapped"); 
} 

這將幫助你.....享受

+0

得益於大兄弟:) – Duaan

+0

歡迎和任何形式的幫助感到自由 –

0

採用兩個委託方法

- (void)mapView:(MKMapView *)mapView didSelectAnnotationView:(MKAnnotationView *)view 
- (void)mapView:(MKMapView *)mapView didDeselectAnnotationView:(MKAnnotationView *)view 
相關問題