Objective c Xcode 4.3.3地图视图,注释未显示

Objective c Xcode 4.3.3地图视图,注释未显示,objective-c,annotations,mkmapview,mkannotationview,Objective C,Annotations,Mkmapview,Mkannotationview,我的注释(homeMark)未显示在mapView中。 我已将viewController委派为IB 由于委托方法中的某些原因 if([annotation isKindOfClass:[HomeMark class]]){ 失败…批注不是“Homemark”类的一部分 我做错了什么 代码 - (IBAction)clubHouse:(id)sender{ MKCoordinateRegion region = { {0.0, 0.0 } , {0.0,0.0} }; regio

我的注释(homeMark)未显示在mapView中。 我已将viewController委派为IB

由于委托方法中的某些原因 if([annotation isKindOfClass:[HomeMark class]]){

失败…批注不是“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;

}
以及注释视图

- (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; 
}
-(MKAnnotationView*)地图视图:(MKMapView*)地图视图注释:(id)注释{
静态NSString*标识符=@“MyLocation”;
if([annotation isKindOfClass:[HomeMark class]]){
MKPinAnnotationView*annotationView=(MKPinAnnotationView*)[mapView出列可重用AnnotationViewWithIdentifier:identifier];
如果(注释视图==nil){
annotationView=[[MKPinAnnotationView alloc]initWithAnnotation:annotation重用标识符:标识符];
}
否则{
annotationView.annotation=注释;
}
annotationView.enabled=是;
annotationView.canShowCallout=是;
返回注释视图;
}
返回零;
}

看起来您指定的坐标不正确,因此注释不是您期望的位置

与此相反:

CLLocationCoordinate2D coord = {
    .latitude = region.center.latitude, 
    .longitude = region.span.longitudeDelta};  // <-- span doesn't make sense
CLLocationCoordinate2D Coordinate={
.纬度=区域.中心.纬度,

.longitude=region.span.longitudeDelta};//我仍然不明白为什么人们会投票,也不说为什么……Stackoverflow是不是到处都是巨魔?非常感谢,我不敢相信我没有看到这个。启用“自动完成”并不总是一个好主意。再次感谢:-D
CLLocationCoordinate2D coord = {
    .latitude = region.center.latitude, 
    .longitude = region.center.longitude};  // <-- not span