Search code examples
iosmkmapviewmkannotation

Annotations, Annotations, Annotations


So `MKAnnotation's. Fun stuff.

My questions:

What's the difference between an annotation's title and its subtitle and how does that affect the visual component of the annotation?

What's the difference between a MKPinAnnotationView and a MKAnnotationView? Are there different types of map annotations in iOS apart from pins?


Solution

  • Title is main heading of your pin.

    The subtitle is actually displaying the address/(common info) of the dropped pin.You can store other deeply information of related to title that is puted on pin.

    enter image description here

    MKAnnotation is a protocol you need to adopt if you wish to show your object on a MKMapView. The coordinate property tells MKMapView where to place it. title and subtitle properties are optional but if you wish to show a callout view you are expected to implement title at a minimum.

    MKAnnotationView visually presents the MKAnnotation on the MKMapView. The image property can be set to determine what to show for the annotation. However you can subclass it and implement drawRect: yourself.

    MKPinAnnotationView is a subclass of MKAnnotationView that uses a Pin graphic as the image property. You can set the pin color and drop animation.

    Don't forget about the leftCalloutAccessoryView and the rightCalloutAccessoryView properties of MKAnnotationView that can be used to customize the callout view.