MGLCalloutView

@protocol MGLCalloutView <NSObject>

A protocol for a UIView subclass that displays information about a selected annotation near that annotation.

  • An object conforming to the MGLAnnotation protocol whose details this callout view displays.

    Declaration

    Objective-C

    @property (readwrite, strong, nonatomic)
        id<MGLAnnotation> _Nonnull representedObject;
  • A view that the user may tap to perform an action. This view is conventionally positioned on the left side of the callout view.

    Declaration

    Objective-C

    @property (readwrite, strong, nonatomic) UIView *_Nonnull leftAccessoryView;
  • A view that the user may tap to perform an action. This view is conventionally positioned on the right side of the callout view.

    Declaration

    Objective-C

    @property (readwrite, strong, nonatomic) UIView *_Nonnull rightAccessoryView;
  • An object conforming to the MGLCalloutViewDelegate method that receives messages related to the callout view’s interactive subviews.

    Declaration

    Objective-C

    @property (readwrite, nonatomic) id<MGLCalloutViewDelegate> _Nullable delegate;

    Swift

    weak var delegate: MGLCalloutViewDelegate? { get set }
  • Presents a callout view by adding it to view and pointing at the given rect of view’s bounds. Constrains the callout to the bounds of the given view.

    Declaration

    Objective-C

    - (void)presentCalloutFromRect:(CGRect)rect
                            inView:(nonnull UIView *)view
                 constrainedToView:(nonnull UIView *)constrainedView
                          animated:(BOOL)animated;

    Swift

    func presentCallout(from rect: CGRect, inView view: Any!, constrainedToView constrainedView: Any!, animated: Bool)
  • Dismisses the callout view.

    Declaration

    Objective-C

    - (void)dismissCalloutAnimated:(BOOL)animated;

    Swift

    func dismissCallout(animated: Bool)
  • A Boolean value indicating whether the callout view should be anchored to the corresponding annotation. You can adjust the callout view’s precise location by overriding -[UIView setCenter:]. The callout view will not be anchored to the annotation if this optional property is unimplemented.

    Declaration

    Objective-C

    @optional
    @property (readonly, getter=isAnchoredToAnnotation, assign, nonatomic)
        BOOL anchoredToAnnotation;

    Swift

    optional var isAnchoredToAnnotation: Bool { get }
  • A Boolean value indicating whether the callout view should be dismissed automatically when the map view’s viewport changes. Note that a single tap on the map view still dismisses the callout view regardless of the value of this property. The callout view will be dismissed if this optional property is unimplemented.

    Declaration

    Objective-C

    @optional
    @property (readonly, assign, nonatomic) BOOL dismissesAutomatically;

    Swift

    optional var dismissesAutomatically: Bool { get }