0

大家好,当用户进入以下代码时,我正在尝试更改注释的图像

- (void)locationManager:(CLLocationManager *)manager   didUpdateToLocation:(CLLocation *)newLocation  fromLocation:(CLLocation *)oldLocation
{
    for (int i = 0; i < [_annotationArray count]; i++)
    {
        //MKAnnotation xxx = [_annotationArray objectAtIndex:i];

        Shadows* shadowObj2 = [_shadowArray objectAtIndex:i];

        NSLog(@"%@",_shadowArray);

        CLLocationCoordinate2D location3;

        location3.latitude  =  [shadowObj2.position_x floatValue];
        location3.longitude =  [shadowObj2.position_y floatValue];

        CLLocation* locationold = [[CLLocation alloc] initWithLatitude:location3.latitude longitude:location3.longitude];

        CLLocationDistance kilometers = [newLocation distanceFromLocation:locationold];

        //temp = [kilometers intValue];

        if (kilometers > 50 && kilometers <100)
        {
            MKAnnotationView* newA = [[MKAnnotationView alloc] initWithAnnotation:[_annotationArray objectAtIndex:i] reuseIdentifier:@"annotation1"];
            newA.image = [UIImage imageNamed:@"shadowS.png"];
            newA.canShowCallout = YES;
        }

        [locationold release];
        //[shadowObj2 release];
    }

}

但我无法更改注释图像请告诉我为什么我不能这样做

4

2 回答 2

2

您可以按照教程制作自定义注释

http://blog.asolutions.com/2010/09/building-custom-map-annotation-callouts-part-1/

于 2011-03-25T09:00:07.797 回答
0

我认为这段代码与地图视图没有任何联系,并且您正在使用新图像分配 MKAnnotationView 的新实例。这不会更改您在地图上已有的现有内容。您需要做的是检查地图视图视图中的距离以进行注释,然后在那里更改其图像。

于 2011-03-25T09:33:32.840 回答