Initializer

init(annotation:reuseIdentifier:)

Initializes and returns a new annotation view.

Declaration

init(annotation: MKAnnotation?, reuseIdentifier: String?)

Parameters

annotation

The annotation object to associate with the new view.

reuseIdentifier

If you plan to reuse the annotation view for similar types of annotations, pass a string to identify it. Although you can pass nil if you do not intend to reuse the view, reusing annotation views is generally recommended.

Return Value

The initialized annotation view or nil if there was a problem initializing the object.

Discussion

The reuse identifier provides a way for you to improve performance by recycling annotation views as they are scrolled on and off of the map. As views are no longer needed, they are moved to a reuse queue by the map view. When a new annotation becomes visible, your application can request a view for that annotation by passing the appropriate reuse identifier string to the dequeueReusableAnnotationView(withIdentifier:) method of MKMapView.

See Also

Creating and Preparing an Annotation View

func prepareForReuse()

Called when the view is removed from the reuse queue.

func prepareForDisplay()

Notifies the annotation view that it is about to be displayed on the map.