2

此行为不会出现在 iOS5 中。

我在 MKMapView 上覆盖了一个视图,当用户触摸内部时,我想锁定 mapview ( setScrollEnabled:NO) 并调整该 UIView 的大小。我在地图视图中添加了一个自定义手势识别器来检查触摸的位置,如果它在覆盖范围之外,用户可以移动/捏合地图以更改区域。

问题是scrollEnabled设置为 NO,即使它总是在我检查它时报告适当的值NSLog,但地图视图仍然会滚动。

代码

我的视图控制器.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];
}

正如我所说,在 iOS 5 中,这按预期工作,当我在我定义的点内触摸时,地图视图区域被锁定。在 iOS 6 中,这样做并不可靠。有时该区域会保持锁定状态,有时它似乎会挣脱。我可以退出视图并返回到它,我无法预测它会如何行动。我在 touchesMoved 中添加了一个 NSLog 来检查_mapView's的状态,scrollEnabledNO按预期返回。

任何人都可以帮忙吗?

4

0 回答 0