如何在MapBox SDK for IOS上检测longtap手势?

时间:2014-12-17 19:20:52

标签: ios mapbox

如何在MapBox SDK for IOS上检测longtap手势?

我尝试下面的代码。 但是从不调用mapLongTap。

-(void)mapInit
{
    RMMBTilesSource *offlineSource = [[RMMBTilesSource alloc] initWithTileSetResource:@"tokyo5" ofType:@"mbtiles"];
    mapView = [[RMMapView alloc] initWithFrame:_mapBaseView.bounds andTilesource:offlineSource];
    mapView.zoom = 0;
    mapView.delegate = self;
    mapView.missingTilesDepth = 5;
    mapView.autoresizingMask = UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleWidth;

    mapView.adjustTilesForRetinaDisplay = YES;    
    UILongPressGestureRecognizer *longPressGesture = [[UILongPressGestureRecognizer alloc]initWithTarget:self action:@selector(mapLongTap:)];
    [longPressGesture setMinimumPressDuration:1.0];

//  [_mapBaseView addGestureRecognizer:longPressGesture];
    [mapView addGestureRecognizer:longPressGesture];

    [self.mapBaseView addSubview:mapView]; 
}

-(void)mapLongTap:(UISwipeGestureRecognizer *)gesture
{
    NSLog(@"LongTap");
}

1 个答案:

答案 0 :(得分:2)

RMMapView已有一个长按手势识别器。见-[RMMapViewDelegate longPressOnMap:at:]