2012-11-14 36 views

回答

0

首先,你想要的位置显示在地图上:

yourMapView.showsUserLocation = YES;

然后,你需要处理的委托方法为用户位置显示annotationview:

- (MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id <MKAnnotation>)annotation { 
    if ([annotation isKindOfClass:[MKUserLocation class]]) { 
     // Create a custom MKAnnotationView here that will display your image. 
    } 
} 

制作确定你的MKMapView正确设置了delegate

0

为此,您需要实施MKAnnotation & MKMapView代表。

执行此方法将默认引脚更改为自定义图像。

- (MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id <MKAnnotation>)annotation 
    { 
    if ([annotation isKindOfClass:[MKUserLocation class]]) 
    { 
     // Create a custom MKAnnotationView here that will display your image. 
     //user current location 
    } 

    static NSString *identifier = @"MyLocation"; 
    if ([annotation isKindOfClass:[MyLocation 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; 
     annotationView.image=[UIImage imageNamed:@"yourImage.png"]; 

     return annotationView; 
    } 

    return nil;  
} 

请参考tutorial

相关问题