2010-09-10 17 views
13

我已延長MapKit的繪製自定義註解圖像用下面的代碼能力:擴展MapView類:viewForAnnotation現在沒有藍點

- (MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id <MKAnnotation>)annotation{ 
    NSLog(@"Drawing a cloud on the map"); 
    MKAnnotationView *view; 
    if(annotation != mapView.userLocation){ 
     view=[[MKAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:@"parkingloc"]; 
     view.image=[UIImage imageNamed:@"placemarkCloud.png"]; 
     [view setCanShowCallout:YES]; 
     [view setRightCalloutAccessoryView:[UIButton buttonWithType:UIButtonTypeDetailDisclosure]]; 
    } 
    else{ 
     view= 
    } 
    return view; 
} 

我的問題是什麼,我應該爲了留住iPhone的內置使視圖=到在藍點。您可以看到我消除了爲該點繪製的自定義圖像,但我不知道如何將其顯示爲默認值。

回答

47

不要把東西放在其他地方。我做了以下檢查。我認爲這是源自蘋果示例代碼。

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

if ([annotation isKindOfClass:[MKUserLocation class]]) { 
    //Don't trample the user location annotation (pulsing blue dot). 
    return nil; 
} 

//Continue on to your regular code here.