ios 地图如何区分人为拖动

看网上,没找到相应的答案,说的大都是地图移动的一些代理方法,但是这个没法分辨出是否是用户手动操作的!正解如下:

试了高德MAMapView,和原生地图MKMapView

MAMapView ,高德提供了下面的方法,后面都带了wasUserAction,用来区分是否是用户操作

//地图将要发生移动时调用此接口

- (void)mapView:(MAMapView *)mapView mapWillMoveByUser:(BOOL)wasUserAction;

//地图移动结束后调用此接口

- (void)mapView:(MAMapView *)mapView mapDidMoveByUser:(BOOL)wasUserAction;

//地图将要发生缩放时调用此接口

- (void)mapView:(MAMapView *)mapView mapWillZoomByUser:(BOOL)wasUserAction;

//地图缩放结束后调用此接口

- (void)mapView:(MAMapView *)mapView mapDidZoomByUser:(BOOL)wasUserAction;

MKMapView,方法翻了个遍,硬是没找到对应的方法,只能想别的办法了

地图里面已经内置好了拖动的手势,关于手势的一些骚操作就不太好处理咱们这个问题了,直接监控touches这个比较low的东西就可以了

- (void)touchesBegan:(NSSet *)touches withEvent:(nullable UIEvent *)event;

- (void)touchesMoved:(NSSet*)touches withEvent:(nullable UIEvent *)event;

- (void)touchesEnded:(NSSet *)touches withEvent:(nullable UIEvent *)event;

这样就可以区分出是不是用户操作的地图了,具体的需求可以在

- (void)touchesMoved:(NSSet*)touches withEvent:(nullable UIEvent *)event;

这个里面区分判断

你可能感兴趣的:(ios 地图如何区分人为拖动)