0

随着新的 iOS 7 更新,我的自定义注释调用配件将永远保持打开状态,除非我重新启动应用程序或刷新注释。例如,如果用户选择了纽约的一个位置,并在查看该位置后返回地图继续搜索,则该纽约位置的调用附件将保持打开状态,直到我重新启动应用程序。当查看多个位置时,这会成为一个问题,因为在地图上打开了许多标注。我的问题是 1,我怎样才能防止这种情况发生?2,为什么现在引入了iOS 7,注释调用仍然保持打开状态,这在以前从来不是问题?感谢您抽出宝贵时间,非常感谢您的帮助,谢谢!

-(MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:     (id<MKAnnotation>)annotation
{
MKAnnotationView *vw = [[MKAnnotationView alloc]initWithAnnotation:annotation reuseIdentifier:@"boardwalk"];

Annotation *myant = (Annotation *)annotation;

//show custom annotation for user loc
if (annotation == mapView.userLocation) 
{
    [mapView.userLocation setTitle:@"I am here!"];
    NSString *latitude = [NSString stringWithFormat:@"%f", mapView.userLocation.coordinate.latitude];
    NSString *longitude = [NSString stringWithFormat:@"%f", mapView.userLocation.coordinate.longitude];
    NSString *userLocDisplay = [NSString stringWithFormat:@"@ Lat: %@ / Lon: %@", latitude, longitude];
    [mapView.userLocation setSubtitle:userLocDisplay];
    return nil;
} 
else if([myant.typeIdentifier isEqualToString:@"park"]) 
{ 
    vw.image =[UIImage imageNamed: @"prkmarker.png"];
}


    //set up annotation view
    vw.enabled = YES;
    vw.canShowCallout = YES;

    UIImageView *imgView = [[UIImageView alloc]
                   initWithImage:[UIImage imageNamed: @"GTAIcon.png"]];
    vw.leftCalloutAccessoryView = imgView;
    vw.rightCalloutAccessoryView = [UIButton buttonWithType:UIButtonTypeDetailDisclosure];

    return vw;
}
4

1 回答 1

1

实现这个委托方法,

- (void)mapView:(MKMapView *)mapView didDeselectAnnotationView:(MKAnnotationView *)view
{
    [view.leftCalloutAccessoryView removeFromSuperview];
    [view.rightCalloutAccessoryView removeFromSuperview];
}
于 2013-09-24T13:42:52.483 回答