禁用MKMapView(iOS 6)中的双击缩放 [英] Disable double tap zoom in MKMapView (iOS 6)

查看:414
本文介绍了禁用MKMapView(iOS 6)中的双击缩放的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在ios 5中,我可以通过使用新的双击手势覆盖它来禁用双击缩放。但似乎双击手势不再出现在mkmapview附带的gesturerecognizer数组中。

  NSArray * gestureRecognizers = [ _mapView gestureRecognizers]; 
for(UIRecognizers中的UIGestureRecognizer *识别器){
NSLog(@%@,识别器);
}

在ios 6中没有返回任何内容,在ios 5中它将返回2个识别器,一个用于单击,一个用于双击。

解决方案

我将查看MKMapView子视图的手势识别器。它可能仍然存在于某个地方。



当然,弄乱另一个视图的GRs有点可疑,并且可能会在下次Apple更改MKMapView的内容时中断......



编辑:为了让其他人阅读本文,检查它是否是 UITapGestureRecognizer numberOfTapsRequired == 2 numberOfTouchesRequired == 1



此外,不要在地图上完全禁用双击,而是考虑在注释上添加双击GR,然后执行 [mapDoubleTapGR requireGestureRecognizerToFail:annotationDoubleTapGR] 。再次,hacky—如果它在下次操作系统更新时中断,请不要怪我!


in ios 5 i was able to disable the double tap zoom by just overriding it with a new double tap gesture. But it seems that the double tap gesture is no longer in the gesturerecognizer array that comes with the mkmapview.

NSArray *gestureRecognizers = [_mapView gestureRecognizers];
for (UIGestureRecognizer *recognizer in gestureRecognizers) {
    NSLog(@"%@", recognizer);
}

returns nothing in ios 6, where in ios 5 it would return 2 recognizers, one for single tap and one for double tap.

解决方案

I'd look through the gesture recognizers of MKMapView's subviews. It's probably still there somewhere.

Of course, messing around with another view's GRs is slightly dubious and will likely break the next time Apple changes something about MKMapView...

EDIT: For the benefit of anyone else reading this, please check that it's a UITapGestureRecognizer and that numberOfTapsRequired == 2 and numberOfTouchesRequired == 1.

Also, instead of disabling double-taps on the map entirely, consider adding a double-tap GR on the annotation and then do [mapDoubleTapGR requireGestureRecognizerToFail:annotationDoubleTapGR]. Again, hacky — don't blame me if it breaks on the next OS update!

这篇关于禁用MKMapView(iOS 6)中的双击缩放的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆