MkMapView setRegion 动画可防止注释视图上的触摸事件
我们有一个带有一堆图像注释的 MKmapView,其中每个图像注释都会响应触摸 通过重写 AnnotationView 子类的这些方法:
-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event;
-(void) TouchesEnded:(NSSet *)touches withEvent:(UIEvent *)event
我们的地图区域就会更新
[MkMapView setRegion:animated:]
每当收到新位置并且距离旧位置足够远以产生影响时,
。我注意到,如果我们将 animated 标志设置为 YES,则很少检测到注释上的触摸(可能是由于主线程正忙于在两个地图区域之间进行动画处理) 。 当我们将动画标志设置为NO时,一切都很好,但地图过渡可能(也可能不会)变得不稳定。
我的问题是,这是否是 [MkMapView setRegion:animated] 函数的 animated 标志的预期行为,或者是否有解决此问题的方法。
提前致谢
We have a MKmapView with a bunch of Image Annotation where each Image annotation responds to touch
by overriding these methods of AnnotationView subclass:
-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event;
-(void) touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event
Our map region is updated using
[MkMapView setRegion:animated:]
whenever the new location is received and is far enough from the old location to make a difference.
What I noticed is that if we set animated flag to YES the touches on our annotation are rarely detected(probably due to the fact that main thread is busy animating between two map regions.
When we set animated flag to NO, everything is fine, but map transition may(or may not) become jerky.
The question I have is whether this is an expected behavior of animated flag of [MkMapView setRegion:animated] function or whether there is a workaround for this issue.
Thanks in advance
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
通常,正在动画的地图视图在动画期间将其 userInteractionEnabled 属性设置为 no。如果您需要更改此行为,您应该对视图进行子类化并重写适当的方法。
或者,您可以在动画持续时间内在地图视图上放置一个透明视图,以捕获特定类型的操作,例如响应双击以停止区域更改。
Typically, the mapview being animated has its userInteractionEnabled property set to no during the animation. If you need to change this behavior, you should subclass the view and override the appropriate methods.
Alternatively, you could place a transparent view over the mapview for the duration of the animation to capture specific types of actions, such as respond to a double-tap to stop the change in region.