我不知道我完全理解什麼觸動你需要檢測或者爲什麼/如何需要檢測它們。但是,由於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 –