2012-06-01 2 views
0

지도 뷰에서 특수 효과를 제거 할 수없는 이유는 무엇입니까?지도 뷰에서 특수 효과를 제거 할 수없는 이유는 무엇입니까?

내 코드 :

  • (공극) viewDidAppear : 애니메이션 (BOOL) { [슈퍼 viewDidAppear : 애니메이션]; [self becomeFirstResponder];

    NSMutableArray * annotations = [[NSMutableArray alloc] init];

    NSString * path = [[NSBundle mainBundle] pathForResource : @ "data"ofType : @ "plist"]; NSDictionary * dict = [NSDictionary dictionaryWithContentsOfFile : 경로];

    if ([[NSUserDefaults standardUserDefaults] boolForKey : @ "blackKey"]) { NSLog (@ "Black is on"));

    NSArray * ann = [dict objectForKey : @ "Category1"];

    찾는 (; 나는 < [앤 카운트] I = 0 int로 난 ++) 다른 {

    NSString *coordinates = [[ann objectAtIndex:i] objectForKey:@"Coordinates"]; 
    
    double realLatitude = [[[coordinates componentsSeparatedByString:@","] objectAtIndex:1] doubleValue]; 
    double realLongitude = [[[coordinates componentsSeparatedByString:@","] objectAtIndex:0] doubleValue]; 
    
    MyAnnotation *myAnnotation = [[MyAnnotation alloc] init]; 
    CLLocationCoordinate2D theCoordinate; 
    theCoordinate.latitude = realLatitude; 
    theCoordinate.longitude = realLongitude; 
    
    myAnnotation.coordinate=CLLocationCoordinate2DMake(realLatitude,realLongitude); 
    
    myAnnotation.title = [[ann objectAtIndex:i] objectForKey:@"Name"]; 
    myAnnotation.subtitle = [[ann objectAtIndex:i] objectForKey:@"Address"]; 
    myAnnotation.icon = [[ann objectAtIndex:0] objectForKey:@"Icon"]; 
    
    if ([[NSUserDefaults standardUserDefaults] boolForKey:@"blackKey"]) 
    { 
        NSLog(@"Black is on"); 
        [mapView addAnnotation:myAnnotation]; 
        [annotations addObject:myAnnotation]; 
    
    } else 
        { 
         NSLog(@"Black is off"); 
    
         [self.mapView removeAnnotation:myAnnotation]; 
    
    
        } 
    
    } 
    

    }

    가 { // 아무것도를 수행하지 }

    } 
    

[self.mapView removeAnnotation:myAnnotation];가 작동하지 않습니다.

답변

0

제거 할 것이 없습니다. 어노테이션을 작성한 다음 blackKey에 대한 확인을 바탕으로 추가 또는 제거합니다. 하지만 제거 할 때 이전에 추가 한 적이 없습니다.

+0

감사합니다. A가 이미 removeAnnotationS를 사용하여 주석을 제거했습니다. –

관련 문제