タッチに反応するようにマップ上にオーバーレイを表示しようとしています。したがって、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 - Protocol に準拠し、メソッド handleGesture: を実装しました。これまでのところ、このメソッドは呼び出されません。
私が間違っていることはありますか?
ありがとう!