在 iOS 5 中检测用户对 MKMapView 的触摸
我在 ViewController 中有一个 MKMapView
,并希望在用户使用以下方法触摸地图时检测用户的手势:
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event;
- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event;
- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event;
- (void)touchesCancelled:(NSSet *)touches withEvent:(UIEvent *)event;
该应用程序在 iOS 3、iOS 4 上运行良好 但是当我使用在 iOS 5 上运行的 iPhone 调试该应用程序时,我看到此消息:
Pre-iOS 5.0 touch delivery method forwarding relied upon. Forwarding -touchesCancelled:withEvent: to <MKAnnotationContainerView: 0x634790; frame = (0 0; 262144 262144); autoresizesSubviews = NO; layer = <CALayer: 0x634710>>
并且未到达上述 4 种方法中的代码。
你知道如何修复它吗?
谢谢。
I have a MKMapView
in a ViewController and would like to detect users' gestures when he/she touches the map with these methods:
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event;
- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event;
- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event;
- (void)touchesCancelled:(NSSet *)touches withEvent:(UIEvent *)event;
The app works fine with iOS 3, iOS 4
but when I debug the app with iPhone running on iOS 5, I see this message:
Pre-iOS 5.0 touch delivery method forwarding relied upon. Forwarding -touchesCancelled:withEvent: to <MKAnnotationContainerView: 0x634790; frame = (0 0; 262144 262144); autoresizesSubviews = NO; layer = <CALayer: 0x634710>>
and the code in the above 4 methods are not reached.
Do you know how to fix it?
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
某种形式的
UIGestureRecognizer
可以帮助您。这是在地图视图上使用点击识别器的示例;如果这不是您要找的,请告诉我。Some form of
UIGestureRecognizer
can help you out. Here's an example of a tap recognizer being used on a map view; let me know if this isn't what you're looking for.