0

我的应用程序存储了来自 CLLocationManager 的数千个纬度、经度详细信息,以在地图上绘制叠加层。现在我想在那个覆盖层上添加手势,并在你触摸覆盖层而不是其他任何地方时显示一些消息。谁能为此想出简单的解决方案?

4

2 回答 2

1

Assuming your overlay is implemented as a view (or is part of a view), you can override the function

- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event;

to test where the user touched the screen.

If the overlay has a bounding rectangle, you can simply compare the user's touch position with the rectangle. This will tell you whether the touch was inside the overlay or not.

于 2013-01-29T08:24:34.837 回答
0

这对我有用。

UITapGestureRecognizer *tgr = [[UITapGestureRecognizer alloc] 
                               initWithTarget:self action:@selector(handleGesture:)];  
tgr.numberOfTapsRequired = 2;
[mapView addGestureRecognizer:tgr];
[tgr release]; 
于 2013-01-29T08:31:43.250 回答