gpt4 book ai didi

ios - 未调用 Touchesbegan 方法

转载 作者:行者123 更新时间:2023-11-29 00:24:21 24 4
gpt4 key购买 nike

touchesBegan 方法未在 GMSmapview 上调用。我希望在触摸或拖动 map 时调用此方法。有人可以让我知道此代码有什么问题

#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");
}

最佳答案

您也可以引用GMSMapViewDelegate Protocol Reference

检测用户是否拖动 map 我觉得用这个方法比较好

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

并检查 gesture 参数是否为 true

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

如前所述,didChangeCameraPosition 被调用了很多次,但由于它也是通过代码设置 map 中心和手势结果调用的,因此您无法真正看出其中的区别单独的方法。

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

在 map 上的相机因手势、动画(例如,用户点击“我的位置”按钮)或通过相机或层上的零长度动画显式更新而发生变化之前调用.

关于ios - 未调用 Touchesbegan 方法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43456108/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com