2016-09-02 3 views
0

私はピンを追加するMKMapViewを持っています。関連グラフィックスは正しくロードされますが、ズームインしたりズームアウトしたりするとグラフィックスが失われ、標準の赤色ピンに変わります。ピン名だけのカスタマイズ(私の開示インジケータが消えても)です。リロード時にカスタムピンを持つMKMapViewが赤い標準ピンに戻ります

これまでのところ、それを試してみて、修正するために私が試した: は、PNG形式の試してみましたより速いデバイス上で確認、代わりに私のカスタムCBAnnotationの通常MKAnnotationに戻って、MKPinAnnotationからMKAnnotationにすべてを変え、ロードカスタムピンのための様々なサンプルコード、地図のオーバーレイの品質が低下していたがロード問題だったが問題が残っていた。

- (void)addPins { 
    mapPinsArray = [[NSMutableArray alloc] init]; 

    for (MapPoint *mappoint in mapPointsArray) { 
     CBAnnotation *annotation = [[CBAnnotation alloc] init]; 
     annotation.coordinate = CLLocationCoordinate2DMake(mappoint.loclat, mappoint.loclong); 
     annotation.title = mappoint.stopAreaName; 
     annotation.mapPoint = mappoint; 
     [mapPinsArray addObject:annotation]; 
     [self.myMapView addAnnotation:annotation]; 
    } 
} 


- (MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(CBAnnotation *)annotation { 

    if ([annotation isKindOfClass:[MKUserLocation class]]) { 
     //do nothing 
     return nil; 
    } else { 
     MKAnnotationView *annotationView = [[MKAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:@"trailPoint"]; 
     annotationView.canShowCallout = YES; 

     ButtonWithData *accessoryViewButton = [[ButtonWithData alloc] initWithFrame:CGRectMake(0, 0, 30, 30)]; 
     [accessoryViewButton setBackgroundImage:[UIImage imageNamed:@"right_arrow"] forState:UIControlStateNormal]; 
     accessoryViewButton.buttonData = annotation.mapPoint; 
     [accessoryViewButton addTarget:self action:@selector(disclosureButtonPressed:) forControlEvents:UIControlEventTouchUpInside]; 
     annotationView.rightCalloutAccessoryView = accessoryViewButton; 

     if (![[NSUserDefaults standardUserDefaults] boolForKey:annotation.mapPoint.stopAnimalName]) { 
      annotationView.image = [annotation.mapPoint lockedPinImage]; 
     } else { 
      annotationView.image = [annotation.mapPoint unlockedPinImage]; 
     } 

     return annotationView; 
    } 
} 

答えて

0

自分自身の問題を修正しました。実際のView ControllerからshowsUserLocation、zoom/scroll/rotateEnabled、showsCompassなどを削除することで、MKMapViewをGenericMapViewにサブクラス化しましたが、これはデリゲートが正しく設定されておらず、viewForAnnotationがピンで呼び出されていないことを意味していましたリロード。

関連する問題