2010-09-10 40 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.