ios – 将平移手势传递给MKMapView

ios – 将平移手势传递给MKMapView,第1张

概述编辑:将使我更清楚我想要实现的目标. 我在MKMapView上有一些注释,我想让它易于拖动.移动注释的标准Apple方法是点击一次然后快速点击并按住并拖动.该应用程序的用户抱怨说这样做太难了. 所以从技术上来说,我想做的就是使用平移手势.问题是MKMapView还使用平移手势来移动地图. 我想做的是当使用平移手势时,检查平移手势是否真的接近注释,如果是,那么让平移手势处理程序移动注释.我有这部分工 编辑:将使我更清楚我想要实现的目标.

我在MKMapVIEw上有一些注释,我想让它易于拖动.移动注释的标准Apple方法是点击一次然后快速点击并按住并拖动.该应用程序的用户抱怨说这样做太难了.

所以从技术上来说,我想做的就是使用平移手势.问题是MKMapVIEw还使用平移手势来移动地图.

我想做的是当使用平移手势时,检查平移手势是否真的接近注释,如果是,那么让平移手势处理程序移动注释.我有这部分工作.

但是如果平移手势不接近注释,则将手势放到MKMapVIEw上以便由它处理.

//编辑结束

我有一种处理平移手势的方法.当我在MKMapVIEw上有一个平移手势时,可以调用此方法.有时我不想在我的方法中处理手势,而是将手势传递到MKMapVIEw以平常地平移/拖动地图.

这是我到目前为止所得到的概述.
平移手势正由该方法处理:

-(voID)panGesture:(UIPanGestureRecognizer*)sender

根据某些逻辑,我想将此手势传递给MKMapVIEw(self.mapVIEw).
有人可以共享代码吗?

我试过[self.mapVIEw gestureRecognizerShouldBegin:sender];但这次电话没有任何结果.

- (voID) addPanGesture{    self.panGesture = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(panGesture:)];    self.panGesture.delegate = self;    [self.panGesture setMinimumNumberOftouches:1];    [self.panGesture setMaximumNumberOftouches:1];    [self.mapVIEw addGestureRecognizer:self.panGesture];}- (BOol)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer     shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer     *)otherGestureRecognizer{    return YES;}- (BOol)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldBerequiredToFailByGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer{    BOol result = NO;    if ((gestureRecognizer == self.panGesture) && [[otherGestureRecognizer vIEw] isDescendantOfVIEw:[gestureRecognizer vIEw]])    {        result = YES;    }    return result;}-(voID)panGesture:(UIPanGestureRecognizer*)sender{    //some logic to see if we will handle the gesture in this method or pass gesture on to the MKMapVIEw    return;}
解决方法

The standard Apple way to move the annotations is to tap once then quickly tap and hold and drag. The users of the app have complained that it is too difficult to do this.

我不这么认为…… 总结

以上是内存溢出为你收集整理的ios – 将平移手势传递给MKMapView全部内容,希望文章能够帮你解决ios – 将平移手势传递给MKMapView所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/web/1032293.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-24
下一篇 2022-05-24

发表评论

登录后才能评论

评论列表(0条)

保存