MKMapView 区域WillChangeAnimated 缩放或平移?

发布于 2024-09-05 09:28:16 字数 231 浏览 3 评论 0原文

我需要知道是否由于缩放或平移而发生了regionWillChangeAnimated。

通过跟踪旧区域跨度并与新区域跨度进行比较以查看是否发生缩放,我能够为 RegionDidChangeAnimated 找出这一点。

RegionWillChangeAnimated 的问题是它是在区域更改之前调用的,因此我无法知道区域跨度是多少。

也许还有另一种方法可以解决这个问题吗?

谢谢。

I need to know whether a regionWillChangeAnimated occurred due to zooming or panning.

I was able to figure this out for regionDidChangeAnimated by keeping track of the old region span and comparing with the new one to see if a zoom occurred.

The problem with regionWillChangeAnimated is that it is called before the region changes so I have no way to know what the region span will be.

Is there another way perhaps to figure this out?

Thanks.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

不再让梦枯萎 2024-09-12 09:28:16

您必须将地图的当前跨度与 mapView:regionWillChangeAnimated: 中的前一个跨度进行比较,在缩放或滚动期间会多次调用该跨度。

您可以使用 breadcrumb 示例项目中的代码:<代码>MKZoomScale currentZoomScale = (CGFloat)(map.bounds.size.width / map.visibleMapRect.size.width);

You have to compare the current span of the map with the previous one in mapView:regionWillChangeAnimated:, which gets called many times during zooming or scrolling.

You can use code from the breadcrumb sample project: MKZoomScale currentZoomScale = (CGFloat)(map.bounds.size.width / map.visibleMapRect.size.width);

吃素的狼 2024-09-12 09:28:16

我相信您需要在regionWillChangeAnimated调用中获取当前区域跨度和中心数据,并在到达regionDidChangeAnimated调用后对其进行比较,但不要在其中执行太多逻辑,否则可能会使用户交互不稳定。

i believe you will need to get the current region span and center data in the regionWillChangeAnimated call and compare it once you get to the regionDidChangeAnimated call but dont do too much logic in there or it can make the user interaction choppy.

攒一口袋星星 2024-09-12 09:28:16

我没有足够的声誉配额来发表评论,但无论如何还是有必要警告一下:您不能仅使用地图的区域跨度来确定是否发生了缩放。对于恒定的缩放级别,地图的水平比例根据纬度而变化。

I don't have the reputation quota to comment, but felt the need to warn anyway: you can't use just the region span of the map to determine if a zoom has occurred. For a constant zoom level, the horizontal scale of the map varies based on latitude.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文