2012-11-11 30 views
0

我想加上註釋, 一個按鈕,但我發現在網上的錯誤時:編譯器錯誤調用dequeueReusableAnnotationViewWithIdentifier

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

這表明:

沒有已知的類方法爲選擇器dequeueReusableAnnotationViewWithIdentifier。

我真的不知道如何解決它我欣賞任何幫助。

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

static NSString *identifier = @"MyLocation"; 
if ([annotation isKindOfClass:[MapAnnotation 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; 

    // Create a UIButton object to add on the 

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

    return annotationView; 
} 
} 

回答

1

改變這一行:

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

與此:

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

以大寫字母的護理:

MapView的是不一樣的MapView的。

+0

Thankssss !!我不知道我有多想念它 – Alaa12