iOS6上MapKit的性能问题 [英] Performance issues with MapKit on iOS6

查看:156
本文介绍了iOS6上MapKit的性能问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

更新到iOS 6后,我注意到在使用多个叠加层平移或缩放MKMapView时,服务器性能会下降。我创建的应用程序有大约600种不同颜色的多边形覆盖,并且在iOS 5上运行无滞后(即使在较旧的iOS设备上),现在在iOS 6上运行极其缓慢(当缩放和平移时),即使在最新设备上也是如此。

After updating to iOS 6 I have noticed sever performance decreases when panning or zooming a MKMapView with multiple overlays. An app I created has approximately 600 polygon overlays of various colours, and ran lag-free (even on older iOS devices) on iOS 5, now runs extremely laggily (when zooming & panning) on iOS 6, even on the latest devices.

我的预感是,这是因为设备必须实际动态创建地图(因为它的矢量基础),而不仅仅是在屏幕上显示切片。

My hunch is that this is due to the fact the device has to actually dynamically create the map (since its vector based) rather than just display tiles onscreen.

有没有人有任何想法可以减少平移或缩放地图时遇到的延迟?

Has anyone got any ideas to reduce the lag experienced when panning or zooming the map?

一些额外的信息,这个低帧速率也会在缩放或平移屏幕上根本没有显示的区域时发生,所以它与创建无关它们出现在屏幕上的叠加层。

Some extra info, this low frame rate also occurs whilst zooming or panning areas where the overlays are not displayed on screen at all, so it is not to do with the creation of the overlays as they come onscreen.

推荐答案

您可以尝试将所有叠加层合并为一个叠加层。这可以大大提高性能。

You can try combining all of your overlays into a single one. This can dramatically boost performance.

我们的想法是创建一个带有包含所有多边形的边界框的叠加层。这样,将始终调用 mapView:viewForOverlay 。为包含所有多边形的叠加层创建属性。然后在叠加视图的 drawMapRect:方法中,测试所有多边形与 mapRect 的交集,并绘制它们必要。这很重要,因为您不希望绘制屏幕外的多边形。

The idea is to create an overlay with a bounding box that encompasses all of your polygons. This way your mapView: viewForOverlay will always be called. Create a property for your overlay that holds all of your polygons. Then in the drawMapRect: method of your overlay view, test all of your polygons for intersection with mapRect and draw them if necessary. This is important since you don't want to be drawing polygons that are off screen.

此策略基于Apple自己的MapKit示例项目。查看 HazardMap ,了解绘制多个对象的示例在单个MKOverlayView中查看 BreadCrumb 如何在 drawMapRect 方法中有效地测试与当前 mapRect 交叉的多边形的示例

This strategy is based on Apple's own MapKit example projects. Check out HazardMap for an example of drawing several objects in a single MKOverlayView and check out BreadCrumb for an example of how to efficiently test polygons for intersection with your current mapRect in the drawMapRect method

这篇关于iOS6上MapKit的性能问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆