6

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?

Imirak
  • 1,323
  • 11
  • 21
sayguh
  • 2,540
  • 4
  • 27
  • 33
  • An MKPointAnnotation is a real annotation--that's not the problem. See http://stackoverflow.com/questions/7884379/mkannotation-not-getting-selected-in-ios5, http://stackoverflow.com/questions/978897/how-to-trigger-mkannotationviews-callout-view-without-touching-the-pin, etc. –  Mar 01 '12 at 18:05

2 Answers2

15

You named your annotation point not annotation:

 [mapView selectAnnotation:point animated:YES];

It happens to the best of us.

QED
  • 9,803
  • 7
  • 50
  • 87
0

swift 3

reminder this action after the addAnnotation.

mapView.addAnnotation(point)

mapView.selectAnnotation(point, animated: true)
米米米
  • 970
  • 7
  • 9