不叫

2017-04-17 86 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 

在地图上改变照相机之前调用,要么是由于一个手势,动画(例如,通过点击“我的位置”按钮的用户)或者通过经由摄像机或一个零明确地更新图层上的长度动画。