2

This behavior doesn't appear in iOS5.

I am overlaying a view on MKMapView, and when the user touches inside, I want to lock the mapview (setScrollEnabled:NO) and resize that UIView. I have added a custom gesture recognizer to the map view to check where the touch is, and if it's outside the overlay, the user can move/pinch the map to change the region.

The problem is that with scrollEnabled set to NO, even though it always reports the appropriate value when I check it with NSLog, the map view scrolls anyway.

Code

MyViewController.m

// viewcontroller that contains the map view; this is the delegate as well
@implementation MyViewController
{
    //private vars
    MKMapView *_mapView;
}

//...

- (void)configTheMap
{
    _mapView = //initwithframe
    //add it as subview, bring it to front
    [_mapView setDelegate:self]

    //setup gesture recognizer
    [gesture setTouchesBeganBlock:^(NSSet *touches, UIEvent *event) {
        //if touch is in the circle set _mapView scrollEnabled:NO
    }];

    //touchesMoved, touchesEnded

    [_mapView addGestureRecognizer:gesture];
}

As I said, in iOS 5, this works as expected, the map view region is locked as I'm touching inside my defined points. In iOS 6, it does so unreliably. Sometimes the region stays locked, sometimes it seems to break free. I can exit the view and return to it, and I can not predict how it will act. I added an NSLog in touchesMoved to check the status of the _mapView's scrollEnabled and it returns NO as expected.

Can anyone help?

ray
  • 1,966
  • 4
  • 24
  • 39
  • Try to implement `gestureRecognizer: shouldRecognizeSimultaneouslyWithGestureRecognizer:` with `return YES`. You need to set the delegate of the gesture recognizer. – Felix Nov 02 '12 at 18:40
  • @phix23 I made `MyViewController` the delegate and implemented that method, but it changed nothing. It already is simultaneously taking input, because the action I want to take place when the user makes the gesture is happening alongside the mapview scrolling. – ray Nov 02 '12 at 20:42
  • I don't find setTouchesBeganBlock in UIGestureRecognizer API. Also did you try to add the gesture recognizer to a custom MKAnnotationView instead? – Felix Nov 02 '12 at 22:08
  • @phix23 I subclassed UIGestureRecognizer as seen here http://stackoverflow.com/a/4064538/3879 – ray Nov 02 '12 at 23:59

0 Answers0