0

如何将数据发送到

 -(MKAnnotationView *)mapView:(MKMapView *)mV viewForAnnotation:
    (id <MKAnnotation>)annotation {

方法。一旦请观察我的代码并给我解决方案。

-(MKAnnotationView *)mapView:(MKMapView *)mV viewForAnnotation: (id <MKAnnotation>)annotation {
    static NSString *defaultPinID = @"com.invasivecode.pin";

    MKAnnotationView *pinView =(MKAnnotationView *)[mapview dequeueReusableAnnotationViewWithIdentifier:defaultPinID];
    NSLog(@"pinData....%@",pinView);
    if (pinView == nil){
        pinView = [[MKAnnotationView alloc]initWithAnnotation:annotation reuseIdentifier:defaultPinID];

        pinView.canShowCallout = YES;
        pinView.enabled = YES;

        pinView.rightCalloutAccessoryView = [UIButton buttonWithType:UIButtonTypeDetailDisclosure];
        [pinView setSelected:YES animated:YES];

        pinView.image = [UIImage imageNamed:@"location.png"];
    }
    else{

    }

    return  pinView;
}
4

1 回答 1

0

如果您向地图添加注释并将包含上面显示的代码的类设置为地图的委托,那么 iOS 将viewForAnnotation在需要重绘它时调用

于 2013-08-08T03:20:47.083 回答