我通过手势识别器在GMSMapView上捕获拖动/平移手势时遇到了一个奇怪的问题.只有在从GMS 1.2更新到1.3.1之后才会出现此问题,其中(引用
documentation),
touches are consumed more agressively by GMSMapView
我有一个UIViewController在其主视图下持有GMSMapView.我发现GMSMapDelegate没有提供处理拖动/平移手势的方法,因此我向UIViewController添加了一个UIPanGestureRecognizer,将其链接到IBAction选择器,并设置引用插座和插座集合,如下面链接的屏幕截图所示:http://i.stack.imgur.com/gktoa.png
因此任何拖动动作都只会触发recognDragOnMap:选择器,如下所示:
-(IBAction)recognizeDragOnMap:(id)sender { NSLog(@"recognizeDragOnMap"); UIGestureRecognizer *gestureRecognizer = (UIGestureRecognizer *)sender; if (gestureRecognizer.state != UIGestureRecognizerStateEnded) { NSLog(@"Still dragging"); return; } NSLog(@"DragEnded"); GMSCameraPosition *position; if ((position = self.mapView.camera)) { self.automaticCameraPositionChange = NO; CLLocationCoordinate2D coordinate = [position targetAsCoordinate]; CLLocation *location = [[CLLocation alloc] initWithLatitude:coordinate.latitude longitude:coordinate.longitude]; [self.origin dragPinToLocation:location]; } else { NSLog(@"No map camera"); } }
此设置过去在GMS 1.2.0下完美运行.更新后,GMSMapView会像过去一样响应手势,但上面的方法永远不会被调用!
任何人都知道是什么和/或如何解决它?