summaryrefslogtreecommitdiff
path: root/platform/ios/src/MGLCompactCalloutView.m
diff options
context:
space:
mode:
authorMinh Nguyễn <mxn@1ec5.org>2016-01-06 15:13:39 -0800
committerMinh Nguyễn <mxn@1ec5.org>2016-01-06 23:43:07 -0800
commit11d99bd890ef2cbadc16beb7289dd818fa86c9df (patch)
tree6b7650c5675fdd0c3b0719e4262ffc4213b83843 /platform/ios/src/MGLCompactCalloutView.m
parentb70fd7ae6947e9d0c2f4b2a2d23069cedac5fa4a (diff)
downloadqtlocation-mapboxgl-11d99bd890ef2cbadc16beb7289dd818fa86c9df.tar.gz
[ios] Refined custom callout view support
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.
Diffstat (limited to 'platform/ios/src/MGLCompactCalloutView.m')
-rw-r--r--platform/ios/src/MGLCompactCalloutView.m31
1 files changed, 31 insertions, 0 deletions
diff --git a/platform/ios/src/MGLCompactCalloutView.m b/platform/ios/src/MGLCompactCalloutView.m
new file mode 100644
index 0000000000..49812c51a4
--- /dev/null
+++ b/platform/ios/src/MGLCompactCalloutView.m
@@ -0,0 +1,31 @@
+#import "MGLCompactCalloutView.h"
+
+#import "MGLAnnotation.h"
+
+@implementation MGLCompactCalloutView
+{
+ id <MGLAnnotation> _representedObject;
+}
+
+@synthesize representedObject = _representedObject;
+
++ (instancetype)platformCalloutView
+{
+ return [[self alloc] init];
+}
+
+- (void)setRepresentedObject:(id <MGLAnnotation>)representedObject
+{
+ _representedObject = representedObject;
+
+ if ([representedObject respondsToSelector:@selector(title)])
+ {
+ self.title = representedObject.title;
+ }
+ if ([representedObject respondsToSelector:@selector(subtitle)])
+ {
+ self.subtitle = representedObject.subtitle;
+ }
+}
+
+@end