2012-06-30 2 views
0

내 주석 (homeMark)이 mapView에 표시되지 않습니다. 내가 대리자 메서드 경우 에서 어떤 이유로 IBXcode 4.3.3 Mapview, 주석이 표시되지 않습니다.

내의 ViewController 대리자를 만들었습니다 ([주석 isKindOfClass : [HomeMark 클래스]]) {

실패 ..... 주석 "의 일부가 아닙니다 Homemark "클래스 ...

내가 뭘 잘못하고 있니?

코드 ...

- (IBAction)clubHouse:(id)sender{ 
    MKCoordinateRegion region = { {0.0, 0.0 } , {0.0,0.0} }; 
    region.center.latitude = 55.305858; 
    region.center.longitude = 12.386036; 


    CLLocationCoordinate2D coord = { 
     .latitude = region.center.latitude, 
     .longitude = region.span.longitudeDelta}; 

    HomeMark *homeMark = [[HomeMark alloc] 
          initWithCoordinate:coord 
          andMarkTitle:@"Klubhus" 
          andMarkSubTitle:@"Stevns Cykel Motion"]; 

    [mapMyView addAnnotation:homeMark]; 

    [mapMyView setMapType:MKMapTypeStandard]; 
    [mapMyView setZoomEnabled:YES]; 
    [mapMyView setScrollEnabled:YES]; 
    region.span.longitudeDelta = 0.007f; 
    region.span.latitudeDelta = 0.007f; 
    [mapMyView setRegion:region animated:YES]; 
    //[mapMyView setDelegate:sender];  
    mapMyView.showsUserLocation = YES; 

} 

그리고 ViewForAnnotation.

- (MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id <MKAnnotation>)annotation { 

    static NSString *identifier = @"MyLocation"; 
    if ([annotation isKindOfClass:[HomeMark class]]) { 

     MKPinAnnotationView *annotationView = (MKPinAnnotationView *) [mapView dequeueReusableAnnotationViewWithIdentifier:identifier]; 
     if (annotationView == nil) { 
      annotationView = [[MKPinAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:identifier]; 
     } 
     else { 
      annotationView.annotation = annotation; 
     } 

     annotationView.enabled = YES; 
     annotationView.canShowCallout = YES; 

     return annotationView; 
    } 

    return nil; 
} 
+0

난 아직도 왜 사람들이 아래로 투표를하지 않고 트롤의 단지 전체에 유래 이유는 ...인가 말을하지 않습니다? – Sirens

답변

1

좌표가 잘못 지정되어 주석이 예상 한 위치에 있지 않은 것처럼 보입니다. 대신이의

:

CLLocationCoordinate2D coord = { 
    .latitude = region.center.latitude, 
    .longitude = region.span.longitudeDelta}; // <-- span doesn't make sense 

이 시도 :

CLLocationCoordinate2D coord = { 
    .latitude = region.center.latitude, 
    .longitude = region.center.longitude}; // <-- not span 
+0

정말 고마워. 내가 이걸 보지 못했다고 믿을 수가 없어. 항상 "자동 완성"을 설정하는 것이 좋습니다. 다시 한번 감사드립니다 .-D –

관련 문제