禁用MKMapView(iOS 6)中的双击缩放 [英] Disable double tap zoom in MKMapView (iOS 6)
问题描述
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屋!