Forwards the SMCalloutView tap delegate

This commit is contained in:
Maciej Swic
2015-09-08 12:11:55 +02:00
committed by Justin R. Miller
parent e3d9fb1715
commit 1a5c452fe3
2 changed files with 19 additions and 2 deletions

View File

@@ -570,6 +570,12 @@ IB_DESIGNABLE
/** @name Managing Annotations */
/* Tells the delegate that the user tapped on the callout view itself.
*
* @param mapView The map view containing the specified annotation.
* @param annotation The annotation whose button was tapped.*/
- (void)mapView:(MGLMapView *)mapView tapOnLabelForAnnotation:(id <MGLAnnotation>)annotation;
/** Tells the delegate that the user tapped one of the annotation's accessory buttons.
*
* Accessory views contain custom content and are positioned on either side of the annotation title text. If a view you specify is a descendant of the `UIControl` class, the map view calls this method as a convenience whenever the user taps your view. You can use this method to respond to taps and perform any actions associated with that control. For example, if your control displayed additional information about the annotation, you could use this method to present a modal panel with that information.

View File

@@ -79,7 +79,7 @@ mbgl::util::UnitBezier MGLUnitBezierForMediaTimingFunction(CAMediaTimingFunction
#pragma mark - Private -
@interface MGLMapView () <UIGestureRecognizerDelegate, GLKViewDelegate, CLLocationManagerDelegate, UIActionSheetDelegate>
@interface MGLMapView () <UIGestureRecognizerDelegate, GLKViewDelegate, CLLocationManagerDelegate, UIActionSheetDelegate, SMCalloutViewDelegate>
@property (nonatomic) EAGLContext *context;
@property (nonatomic) GLKView *glView;
@@ -1451,6 +1451,14 @@ std::chrono::steady_clock::duration secondsAsDuration(float duration)
}
}
- (void)calloutViewClicked:(SMCalloutView *__attribute__ ((unused)))calloutView
{
if ([self.delegate respondsToSelector:@selector(mapView:tapOnLabelForAnnotation:)])
{
[self.delegate mapView:self tapOnLabelForAnnotation:self.selectedAnnotation];
}
}
- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer
{
NSArray *validSimultaneousGestures = @[ self.pan, self.pinch, self.rotate ];
@@ -2445,7 +2453,10 @@ CLLocationCoordinate2D MGLLocationCoordinate2DFromLatLng(mbgl::LatLng latLng)
[self.selectedAnnotationCalloutView.rightAccessoryView addGestureRecognizer:calloutAccessoryTap];
}
}
// set annotation delegate to handle taps on the callout view
self.selectedAnnotationCalloutView.delegate = self;
// present popup
[self.selectedAnnotationCalloutView presentCalloutFromRect:calloutBounds
inView:self.glView