2011-03-25 82 views
0

大家好我试图改变注释的图像时,用户走在下面的代码MapView的注释调整

- (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]; 
    } 

} 

,但我无法改变标注图像,请告诉我为什么我不能够做到这一点

回答

0

我不认为这个代码与地图的任何连接view和u正在为新图像分配一个MKAnnotationView的新实例。这不会更改您在地图上已有的现有设置。你需要做的是在mapview的视图中检查注释的距离,然后在那里改变它的图像。