2

我试图在我的地图上叠加以响应触摸。因此,我想为在方法 mapView:viewForOverlay 中创建的 MKOverlayView 添加一个用于点击的 UIGestureRecognizer。

我在这个方法中添加了以下代码:

if ([overlay isKindOfClass:[MKPolygon class]])
{

    MKPolygonView*    aView = [[MKPolygonView alloc] initWithPolygon:(MKPolygon*)overlay];

    UITapGestureRecognizer* tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(handleGesture:)];

    tap.delegate = self;
    aView.fillColor = color;
    aView.strokeColor = color;
    aView.lineWidth = 2;
    [aView addGestureRecognizer:tap];

    return aView;
}

此外,我符合 UIGestureRecognizerDelegate - 协议并实现了方法 handleGesture:。到目前为止,从未调用过此方法。

任何想法我做错了什么?

谢谢!

4

0 回答 0