summaryrefslogtreecommitdiff
path: root/platform
diff options
context:
space:
mode:
authorMinh Nguyễn <mxn@1ec5.org>2015-12-05 10:23:09 -0800
committerMinh Nguyễn <mxn@1ec5.org>2015-12-13 17:26:53 -0800
commitfdff7901e2480cd683317eec2e490fc704612a0b (patch)
tree0dcac1286a3b094945716729f0056d7f79e241df /platform
parentbab3935431ddec4d2762d2c010eac7530fd26856 (diff)
downloadqtlocation-mapboxgl-fdff7901e2480cd683317eec2e490fc704612a0b.tar.gz
[osx] Default callout view controller
Diffstat (limited to 'platform')
-rw-r--r--platform/osx/src/MGLMapView.mm18
1 files changed, 15 insertions, 3 deletions
diff --git a/platform/osx/src/MGLMapView.mm b/platform/osx/src/MGLMapView.mm
index a9ab336263..2796c5fdb5 100644
--- a/platform/osx/src/MGLMapView.mm
+++ b/platform/osx/src/MGLMapView.mm
@@ -1587,11 +1587,14 @@ public:
NSViewController *viewController;
if ([self.delegate respondsToSelector:@selector(mapView:calloutViewControllerForAnnotation:)]) {
- viewController = [self.delegate mapView:self calloutViewControllerForAnnotation:annotation];
+ NSViewController *viewControllerFromDelegate = [self.delegate mapView:self
+ calloutViewControllerForAnnotation:annotation];
+ if (viewControllerFromDelegate) {
+ viewController = viewControllerFromDelegate;
+ }
}
if (!viewController) {
- viewController = [[NSViewController alloc] initWithNibName:@"MGLAnnotationCallout"
- bundle:[NSBundle mgl_frameworkBundle]];
+ viewController = self.calloutViewController;
}
NSAssert(viewController, @"Unable to load MGLAnnotationCallout view controller");
// The popover’s view controller can bind to KVO-compliant key paths of the
@@ -1602,6 +1605,15 @@ public:
return callout;
}
+- (NSViewController *)calloutViewController {
+ // Lazily load a default view controller.
+ if (!_calloutViewController) {
+ _calloutViewController = [[NSViewController alloc] initWithNibName:@"MGLAnnotationCallout"
+ bundle:[NSBundle mgl_frameworkBundle]];
+ }
+ return _calloutViewController;
+}
+
/// Returns the rectangle that represents the annotation image of the annotation
/// with the given tag. This rectangle is fitted to the image’s alignment rect
/// and is appropriate for positioning a popover.