Adding annotations to a map view
In Chapter 12, Finishing Up Your User Interface, you added a map view to the Map screen. In previous sections, you added the MapLocations.plist
file to your project and created the RestaurantItem
and MapDataManager
classes. Remember the MVC design pattern? At this point, you have created the views and models for the Map screen, so all you need now is the view controller.
The view controller will be responsible for the following tasks:
- Adding
RestaurantItem
instances, which conform to theMKAnnotation
protocol, to the map view. - For
RestaurantItem
instances within the region displayed in the map view, provideMKAnnotationView
instances requested by the map view. - Provide custom
MKAnnotationView
instances which display a callout bubble containing a button when tapped, and present the Restaurant Detail screen when the button is tapped.
You’ll start by creating the MapViewController
class as the view controller...