如何将数据发送到
-(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;
}
答案 0 :(得分:0)
如果您向地图添加注释并将包含上面显示的代码的类设置为地图的委托,那么当需要重绘时,iOS会调用viewForAnnotation