我不知道我完全理解什么触动你需要检测或者为什么/如何需要检测它们。但是,由于touchesbegan,我在GMSMapView之上检测用户平移手势的类似问题:只调用一次。
我有我自己的“当前位置”按钮,让用户在地图上开/关切换地图。我需要找出用户何时“平移”地图而不中断地图接收的平移(我仍然希望地图也能平移)。
首先,我创建的地图:
// Creates Map centered at current location
GMSCameraPosition *camera = [GMSCameraPosition cameraWithLatitude:theLocationManager.location.coordinate.latitude
Longitude:theLocationManager.location.coordinate.longitude
zoom:15];
theMapView = [GMSMapView mapWithFrame:CGRectZero camera:camera];
theMapView.myLocationEnabled = YES;
theMapView.delegate = self;
theMapView.camera = camera;
self.view = theMapView;
然后创建了一个平移手势识别,并将其加入到theMapView
的手势识别属性。我就确定了目标与选择方法设置为self
didPan:
// Watch for pan
UIPanGestureRecognizer *panRecognizer = [[UIPanGestureRecognizer alloc] initWithTarget: self action:@selector(didPan:)];
theMapView.gestureRecognizers = @[panRecognizer];
最后,在同一个主文件,我实现了didPan:
方法反应,当用户锅:
- (void) didPan:(UIPanGestureRecognizer*) gestureRecognizer
{
NSLog(@"DID PAN");
// React here to user's pan
}
其真正完美答案。谢谢+1 –