2012-10-20 4 views
-1

이 질문은 이미 요청되었지만 찾을 수 없습니다. 내가 얻는 오류는 정말로 나에게 두통을주고있다!MKMapView NSUnknownKeyException

Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<MapViewController 0x8095670> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key mapView.' 

나는 주석이 잘 살고되고 이벤트가 호출 될 때이라고 생각합니다. 내 코드 :

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

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

    MKPinAnnotationView *annotationView = 
    (MKPinAnnotationView *)[myMapView dequeueReusableAnnotationViewWithIdentifier:identifier]; 

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

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

    // Create a UIButton object to add on the 
    UIButton *rightButton = [UIButton buttonWithType:UIButtonTypeDetailDisclosure]; 
    [rightButton setTitle:annotation.title forState:UIControlStateNormal]; 
    [annotationView setRightCalloutAccessoryView:rightButton]; 

    UIButton *leftButton = [UIButton buttonWithType:UIButtonTypeInfoDark]; 
    [leftButton setTitle:annotation.title forState:UIControlStateNormal]; 
    [annotationView setLeftCalloutAccessoryView:leftButton]; 

    return annotationView; 
} 

return nil; 
} 

나는 ObjC에게 조금 새내기입니다. 그러나 더 많은 검사를위한 코드가 필요하면 보내 주시면 기쁩니다!

+1

MapViewController xib의 IBOutlet이 모두 올바르게 연결되어 있는지 확인하십시오. – Anna

답변

0

표시된 코드에서 볼 수는 없지만 컨트롤러에서 mapview를 설정하려고 시도했지만 어딘가에 속성으로 설정하지 않았습니까? 신고서에 잘못된 이름을 사용했을 수도 있습니다. viewcontroller.mapView = ....