Skip to content
This repository has been archived by the owner on Aug 8, 2023. It is now read-only.

Custom callout views #3456

Merged
merged 3 commits into from Jan 7, 2016
Merged

Custom callout views #3456

merged 3 commits into from Jan 7, 2016

Conversation

1ec5
Copy link
Contributor

@1ec5 1ec5 commented Jan 6, 2016

This PR is a continuation of #3322 by @RomainQuidet with the following additional changes:

  • Renamed MGLCalloutView to MGLCompactCalloutView and MGLCalloutViewProtocol to MGLCalloutView to avoid the awkward situation of having to put “Protocol” in a protocol name (for Swift support).
  • Replaced individual title and subtitle properties in MGLCalloutView with a single representedObject property that lets you use custom annotation properties in the custom callout view.
  • Overrode a problematic SMCalloutView method that treated its own class as an umbrella class. This SDK doesn’t support iOS 5, so there’s no need to support “classic” callouts.
  • Documented new APIs.

/cc @friedbunny

@1ec5 1ec5 added feature iOS Mapbox Maps SDK for iOS refactor labels Jan 6, 2016
@1ec5 1ec5 self-assigned this Jan 6, 2016
@1ec5 1ec5 added this to the ios-v3.1.0 milestone Jan 6, 2016
@1ec5 1ec5 mentioned this pull request Jan 6, 2016
@bsudekum
Copy link

bsudekum commented Jan 6, 2016

🙏

Romain Quidet and others added 3 commits January 6, 2016 23:42
Renamed MGLCalloutView to MGLCompactCalloutView and MGLCalloutViewProtocol to MGLCalloutView to avoid an awkward workaround for a Swift name collision. Replaced individual title and subtitle properties with a single representedObject property that lets you use custom annotation properties in the custom callout view. Overrode a problematic SMCalloutView method. Added lots more documentation.
@1ec5 1ec5 force-pushed the 1ec5-custom-callout-view-2211 branch from f322aca to 11d99bd Compare January 7, 2016 07:45
@1ec5 1ec5 merged commit 11d99bd into master Jan 7, 2016
@1ec5 1ec5 removed the in progress label Jan 7, 2016
@1ec5 1ec5 deleted the 1ec5-custom-callout-view-2211 branch January 7, 2016 08:05
@RomainQuidet
Copy link
Contributor

Great thanks.

@1ec5
Copy link
Contributor Author

1ec5 commented Jan 7, 2016

No, thank you! 😊

1ec5 added a commit that referenced this pull request Jan 10, 2016
@1ec5
Copy link
Contributor Author

1ec5 commented Jan 10, 2016

Categorized MGLCalloutView and MGLCalloutViewDelegate in jazzy-generated documentation in cd94049.

1ec5 added a commit that referenced this pull request Feb 10, 2016
#3322 #3456 replaced SMCalloutViewDelegate conformance with MGLCalloutViewDelegate conformance. Unfortunately, the two protocols differ in some symbols. This change restores SMCalloutViewDelegate methods alongside MGLCalloutViewDelegate methods.

Fixes #3871.
@gurumaheshPCS
Copy link

Hi Mapbox,
i have some custom annotation view. When user selects any annotation i need to show. in mabox V:3.1.0 we got new method for that in below.

  • (nullable UIView *)mapView:(MGLMapView *)mapView calloutViewForAnnotation:(id )annotation;

How can i use this method? Can anyone provide some example for this...

@1ec5
Copy link
Contributor Author

1ec5 commented Feb 20, 2016

Here’s the documentation for -mapView:calloutViewForAnnotation:. The iosapp demo application has an example implementation using a custom MBXCustomCalloutView class.

@gurumaheshPCS
Copy link

Thanks for providing Demo App. But in my callout view i have two buttons. i am not able to get the button actions when i tap the button. Can you help how the button action will fire.
Thanks,
Gurumahesh Vunna
9703940400

On 20-Feb-2016, at 11:31 AM, Minh Nguyễn notifications@github.com wrote:

Here’s the documentation for -mapView:calloutViewForAnnotation: https://www.mapbox.com/ios-sdk/api/3.1.1/Protocols/MGLMapViewDelegate.html#/c:objc%28pl%29MGLMapViewDelegate%28im%29mapView:calloutViewForAnnotation:. The iosapp demo application has an example implementation https://github.com/mapbox/mapbox-gl-native/blob/ios-v3.1.1/ios/app/MBXViewController.mm#L657-L667 using a custom MBXCustomCalloutView https://github.com/mapbox/mapbox-gl-native/blob/ios-v3.1.1/ios/app/MBXCustomCalloutView.m class.


Reply to this email directly or view it on GitHub #3456 (comment).

@1ec5
Copy link
Contributor Author

1ec5 commented Feb 23, 2016

Your MGLCalloutView-conforming class should somehow implement the leftAccessoryView and rightAccessoryView methods. In the MBXCustomCalloutView example, those methods are implemented as properties, so the code that creates the MBXCustomCalloutView would be responsible for setting leftAccessoryView to the tappable button. In your case, however, your callout view class probably already knows about the button, so it can set leftAccessoryView to that button inside -initWithFrame:.

If you have any further questions about this feature, please contact our Support team, who would be happy to assist you. (They also help us write documentation, so please let them know about things that can be explained better.)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
feature iOS Mapbox Maps SDK for iOS refactor
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants