0

私のアプリは、ユーザーの現在地を定期的に追跡する必要があります。デフォルトの青いドット アイコンを使用したくありません。ここにそれを変更するための私のコードがあります。しかし、うまくいきません。

    - (MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id <MKAnnotation>)annotation {
    static NSString *identifier = @"MyLocation";
    if ([annotation isKindOfClass:[MyLocation class]]) {
        MKAnnotationView *annotationView = (MKAnnotationView *) [_mapView dequeueReusableAnnotationViewWithIdentifier:identifier];
        if (annotationView == nil) {
            annotationView = [[MKAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:identifier];
            annotationView.enabled = YES;
            annotationView.canShowCallout = YES;
            if(annotation != mapView.userLocation){
                annotationView.image = [UIImage imageNamed:@"person.png"];
            }
            else{
                annotationView.image = [UIImage imageNamed:@"selflocation.png"];
            }
            annotationView.rightCalloutAccessoryView = [UIButton buttonWithType:UIButtonTypeDetailDisclosure];
        } else {
            annotationView.annotation = annotation;
        }
        return annotationView;
 }

    return nil;
}

私は声明を見つけました:

annotationView.image = [UIImage imageNamed:@"selflocation.png"];

も呼び出されません。

4

0 に答える 0