Disable double tap zoom in MKMapView (iOS 6)

后端 未结 5 958
清歌不尽
清歌不尽 2021-01-12 17:57

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 gesturer

5条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2021-01-12 18:11

    This works for me:

        //INIT the MKMapView    
        -(id) init{
             ...
             [self getGesturesRecursive:mapView];
             ...
        }
    

    And then let the recursive function loop through the subviews and find the GR:s.

        -(void)getGesturesRecursive:(UIView*)v{
             NSArray *gestureRecognizers = [v gestureRecognizers];
             for (UIGestureRecognizer *recognizer in gestureRecognizers) {
                 if ([recognizer isKindOfClass:[UITapGestureRecognizer class]]) {                  
                    [v removeGestureRecognizer:recognizer];
                 }
            }
    
            for (UIView *v1 in v.subviews){
                [self getGesturesRecursive:v1];
            }
        }
    

    This example removes all tap-GR:s. But I guess you can specify to remove whatever you'd like.

提交回复
热议问题