不叫

2017-04-17 70 views
0

不叫上GMSmapview.I的touchesBegan方法,期待這種方法Touchbegan方法被觸摸或拖動地圖上叫。可有人讓我知道什麼是錯,此代碼不叫

#import "ViewController.h" 

@interface ViewController() 

@end 

@implementation ViewController 

- (void)viewDidLoad { 
    [super viewDidLoad]; 
    [self.view setUserInteractionEnabled:YES]; 
    _mapview.userInteractionEnabled=YES; 
    _mapview.settings.consumesGesturesInView = false; 
} 

- (void)touchesBegan:(NSSet<UITouch *> *)touches 
      withEvent:(UIEvent *)event{ 

    NSLog(@"touchbegan started"); 
} 

- (void)touchesMoved:(NSSet<UITouch *> *)touches 
      withEvent:(UIEvent *)event{ 
    NSLog(@"touchesMoved started"); 
} 

- (void)touchesEnded:(NSSet<UITouch *> *)touches 
      withEvent:(UIEvent *)event{ 
    NSLog(@"touchesEnded started"); 
} 
+0

爲什麼你要使用的touchesBegan方法使用GMSMapView中mapdiddrag或mapdidtap方法 –

+0

我想要得到的緯度第二日誌,其中用戶觸摸map..can你提供有關如何做簡單說明這 – tnishanth

+0

'爲(UIGestureRecognizer *識別器是KindOfClass:UIPanGestureRecognizer] {識別器.addTarget ...;}}''在這種情況下可能會有一些用處。 – Brandon

回答

1

您也可以參考GMSMapViewDelegate Protocol Reference

要檢測用戶拖動地圖,我認爲這是更好地使用這種方法

- (void)mapView:(GMSMapView *)mapView willMove:(BOOL)gesture 

,並檢查是否gesture參數是true

- (void) mapView:(GMSMapView *)mapView didChangeCameraPosition:(GMSCameraPosition *)position 

didChangeCameraPosition被稱爲,如前所述,很多次,但因爲它也是由兩個設置從代碼中的地圖中心,併爲手勢的結果叫你實在看不出,只與該方法的差異。

- (void) mapView:(GMSMapView *)mapView idleAtCameraPosition:(GMSCameraPosition *)position 

在地圖上改變照相機之前調用,要麼是由於一個手勢,動畫(例如,通過點擊「我的位置」按鈕的用戶)或者通過經由攝像機或一個零明確地更新圖層上的長度動畫。