Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

mapkit show annotation by default

I have an annotation showing in mapkit with a custom image, showing fine,

but the annotation shows after taping the pin,

how can I have the annotation showing by default?, when I start the view? whit out tapping the pin.

- (MKAnnotationView *)mapView:(MKMapView *)mv viewForAnnotation:(id <MKAnnotation>)annotation
{


    if([annotation isKindOfClass:[MKUserLocation class]])
        return nil; 

    NSString *annotationIdentifier = @"PinViewAnnotation"; 

    MKPinAnnotationView *pinView = (MKPinAnnotationView *) [mapView 
                                                            dequeueReusableAnnotationViewWithIdentifier:annotationIdentifier];


    if (!pinView) 
    {
        pinView = [[[MKPinAnnotationView alloc] 
                    initWithAnnotation:annotation 
                    reuseIdentifier:annotationIdentifier] autorelease];

        [pinView setPinColor:MKPinAnnotationColorGreen];
        pinView.animatesDrop = YES; 
        pinView.canShowCallout = YES; 

        UIImageView *houseIconView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"tijereta.png"]];
        pinView.leftCalloutAccessoryView = houseIconView; 
        [houseIconView release];        
    }
    else 
    {
        pinView.annotation = annotation;
    }

    return pinView; 

}

thanks

like image 694
manuelBetancurt Avatar asked Apr 12 '12 13:04

manuelBetancurt


1 Answers

you can use this

[mapView selectAnnotation:pinView animated:YES]; //here pinView is your annotation and mapview is your map

hope that helped

like image 56
Ajeet Pratap Maurya Avatar answered Sep 28 '22 03:09

Ajeet Pratap Maurya