Reputation: 1073
I have implemented one map application in which i have display pin animation for current location.When i click on the pin at that time annotation view will open. But i want to display annotation view without clicking on pin.Is it possible if possible then please give me idea about that.
Thanks in advance.
Upvotes: 5
Views: 2083
Reputation: 425
Try out:
It seems that [mapView selectAnnotation:annotation animated:YES]
works too.
Hope this helps.
Upvotes: 5
Reputation: 3330
We can show the annotation with out clicking on it. Use the following code:
- (MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id <MKAnnotation>)annotation{
static NSString *identifier = @"Pin";
MKPinAnnotationView *pin = [[MKPinAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:identifier];
pin.canShowCallout = YES;
[pin setSelected:YES animated:NO];
return [pin autorelease];
}
Upvotes: -2
Reputation: 10009
You just need to find your MKAnnotationView instance you want to select and call -setSelected:animated:
.
For example, you can loop your annotations of an MKMapView like this:
for (YOURCLASSHERE *a in mapView.annotations) {
// Your current position (if shown) is an annotation as well. Thus check for the right class!
if ([a isKindOfClass:[YOURCLASSHERE class]]) {
// insert some smart if statement here, if you have multiple annotations!
[[mapView viewForAnnotation:a] setSelected:YES animated:YES];
}
}
YOURCLASSHERE is your class which implements the MKAnnotation
protocol.
Of course the loop is superfluous if you already know your annotationView.
Upvotes: 2