1
我正在添加自定義註釋以及用戶的當前位置默認氣泡註釋,但用戶位置註釋在未專注於mapview的某個時間後會更改爲其他自定義位置。用戶位置氣泡註釋更改爲自定義註釋
我viewForAnnotation方法是:
-(MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id<MKAnnotation>)annotation
{
NSString* annotationidentifier = @"customview";
CustomAnnotationView *customannotationview = (CustomAnnotationView*) [self.mapview dequeueReusableAnnotationViewWithIdentifier:annotationidentifier];
if([annotation isKindOfClass:[MKUserLocation class]])
{
customannotationview = [[CustomAnnotationView alloc] initWithAnnotationWithImage:annotation reuseIdentifier:annotationidentifier annotationviewimage:[UIImage imageNamed:@"location pin28.png"]];
customannotationview.canShowCallout = YES;
return customannotationview;
}
else if(![annotation isKindOfClass:[MKUserLocation class]] && annotation != _mapview.userLocation && (annotation.coordinate.latitude != _locationmanager.location.coordinate.latitude && annotation.coordinate.longitude != _locationmanager.location.coordinate.longitude))
{
customannotationview = [[CustomAnnotationView alloc] initWithAnnotationWithImage:annotation reuseIdentifier:annotationidentifier annotationviewimage:[UIImage imageNamed:@"image1.png"]];
return customannotationview;
}
return customannotationview;
}
我已經把情況在自定義的註釋,但仍然在一段時間後,如果用戶位置是失焦的somtime它改變image1.png
感謝您的支持,但我通過在userlocation註釋中返回nil來替代customannotationview來解決此問題。 – khushalbokadey 2012-07-09 12:40:02