2011-03-25 161 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的視圖中檢查註釋的距離,然後在那裏改變它的圖像。