开发者

MapView annotation

I have added an image on annotation view and when i am touching annotation view its image is changeing into red pin can any one tell me what's he reason for it

- (MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id <MKAnnotation>)annotation 
{
    MKPinAnnotationView* newAnnotation = [[MKPinAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:@"annotation1"];

    if (annotation == _mapView.userLocation)
    {
        newAnnotation.rightCalloutAccessoryView = [UIButton开发者_开发技巧 buttonWithType:UIButtonTypeDetailDisclosure];
        return nil;
    }

    //[newAnnotation setSelected:YES];
    newAnnotation.image = [UIImage imageNamed:@"sample.png"];
    newAnnotation.rightCalloutAccessoryView = [UIButton buttonWithType:UIButtonTypeDetailDisclosure];
    newAnnotation.canShowCallout = YES;
    [newAnnotation retain];

    return newAnnotation;

}


Make the newAnnotation a MKAnnotationView rather than a MKPinAnnotationView.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜