I must be misunderstanding



I’m enjoying working through the book.

In reading the WhereAmI project, I was under the impression that when one typed a name into the UITextField, that an annotation would be created and appear on the map. However I type, the wheel spins, the wheel stops and nothing changes on the map. This is true on the simulators, iphone, ipad and also when I use the code with the book running on the simulators.

So, either I’m not understanding what an annotation should do or something is wrong.

Help! (Please)



Things I would check for:

The outlet from WhereamiAppDelegate to mapView is connected to the MKMapView in IB.
The outlet from the MKMapView to delegate is connected to the WhereamiAppDelegate in IB.
The delegate methods for CLLocationManager are being called: put an NSLog in there to make sure.

Usually, if something doesn’t seem to be working right, I pepper all related code with NSLog statements to make sure I’m getting to the points I believe I should be getting to.


Thanks for the response.

It may not have been clear, but I see the same results both on the code that I typed in and on the code downloaded from here. A red pushpin appears, but not the text. I would expect that an annotation should have some text (since we did type something into the text field). I was expecting something more like the Map application where it puts a red push pin in the map and identifies the location textually.

I will however try to fix both of the code sets.




It seems that in order to see the text annotation, one has to click/touch the pushpin. It doesn’t seem to be especially easy to make that visible always, but it must be possible.




Try adding this line:

[mapView selectAnnotation:mp animated:YES];

After adding the annotation.



Correct, you do have to select the pin to see the callout information. Technically, you can programmatically tell an MKAnnotationView to show its callout view with setSelected:animated: or setSelected:. However, the documentation says not to do this. I imagine it is because that as the number of callout views visible grows, a lot of the map would become obscured.