Contents

register(_:forAnnotationViewWithReuseIdentifier:)

Registers an annotation view class that the map can create automatically.

Declaration

func register(_ viewClass: AnyClass?, forAnnotationViewWithReuseIdentifier identifier: String)

Parameters

  • viewClass:

    The class of an annotation view that you use in your map. The class needs to be a subclass of Mkannotationview.

  • identifier:

    The reuse identifier to associate with the specified class. This parameter can’t be nil or an empty string.

Discussion

Use this method to register one or more views that you use to display annotations on your map. Register your classes before adding any annotations to the map.

When you register an annotation view class using this method, the dequeueReusableAnnotationView(withIdentifier:for:) method uses the provided identifier to create the view that you register. It creates a new view only if an existing view isn’t available for reuse.

See Also

Creating annotation views