通常情况下,如果您启用了showuserlocation,并转到mapview,则会有蓝点动态放大到用户的当前位置。但是,如果为不同的颜色目的创建了一个自定义注解别针,则showuserlocation功能将消失。newAnnotation下面的代码是罪魁祸首。您如何既有自定义引脚,也显示用户定位能力不受干扰。
- (MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id <MKAnnotation>)annotation
{
if ([[annotation title] isEqualToString:@"Destination"])
{
MKPinAnnotationView *newAnnotation = [[MKPinAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:@"greenpin"];
newAnnotation.pinColor = MKPinAnnotationColorGreen;
newAnnotation.animatesDrop = YES;
newAnnotation.canShowCallout = YES;
return newAnnotation;
}
}发布于 2011-12-31 15:32:24
尝尝这个
- (MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id <MKAnnotation>)annotation
{
// if it's the user location, just return nil.
if ([annotation isKindOfClass:[MKUserLocation class]])
return nil;
if ([[annotation title] isEqualToString:@"Destination"])
{
MKPinAnnotationView *newAnnotation = [[MKPinAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:@"greenpin"];
newAnnotation.pinColor = MKPinAnnotationColorGreen;
newAnnotation.animatesDrop = YES;
newAnnotation.canShowCallout = YES;
return newAnnotation;
}
}https://stackoverflow.com/questions/8686654
复制相似问题