开发者

Stealing two-finger pan from mkmapview

I've placed a UIview above an MKMapView with the intention of stealing the two-finger pan from the map view when I am tracking a user's location. If you notice Google m开发者_开发问答aps app does this on the phone as well.

But I'm at a loss as to how to do it. I want to be able to enable it and disable it at will depending on whether the location is being tracked or not. All other gestures and touches should be passed onto the mapview

thanks in advance.


Assuming you're going for OS 4 and above, the easy way is NOT to use a UIView, but instead to add a gesture-recognizer directly onto the mapview, e.g.:

UIPanGestureRecognizer* gest = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(handlePanGesture:)];
[mapView addGestureRecognizer:gest];

...and then all swipe gestures (in that case) would get passed to [self handlePanGesture:(UIPanGestureRecognizer*) x];

If you look in the docs around gesture recognizers, there's a wide variety of options, and you can add them to a pretty fine-level of granularity (tap vs swipe, how many fingers used, etc)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜