sayguh
sayguh

Reputation: 2550

MKPointAnnotation - Default show title and animated?

In my viewWillAppear for a view I have

MKPointAnnotation *point = [[MKPointAnnotation alloc] init];

[point setCoordinate:(myLocation)];
[point setTitle:@"Here it is!"];

[mapView addAnnotation:point];

[mapView setRegion:adjustedRegion animated:YES]; 

This adds the point to the map as I intend. However I have to tap it in order to see the callout.

How can I have it show the callout by default?

I tried adding this right after: [self.mapView selectAnnotation:annotation animated:YES];

But it didn't seem to work... do I have to use a real annotation and not a MKPointAnnotation to do this?

Upvotes: 6

Views: 7532

Answers (2)

米米米
米米米

Reputation: 990

swift 3

reminder this action after the addAnnotation.

mapView.addAnnotation(point)

mapView.selectAnnotation(point, animated: true)

Upvotes: 0

QED
QED

Reputation: 9933

You named your annotation point not annotation:

 [mapView selectAnnotation:point animated:YES];

It happens to the best of us.

Upvotes: 15

Related Questions