如何清除MKMapView的地图图块缓存? [英] How can I clear MKMapView's cache of map tiles?

查看:123
本文介绍了如何清除MKMapView的地图图块缓存?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发基于MKMapView的iPhone / iPad地图应用程序,该应用程序覆盖我自己的基本底图,即使在用户离线且无法访问Google的地图图块服务器时也能提供一些有限的功能。

I am working on an MKMapView based iPhone / iPad mapping app that overlays my own basic base map to provide for some limited functionality even when users are offline and can not reach Google's map tile server.

此功能正常运行 - 但我很难在每次新构建后测试它,因为我找不到刷新/重置iOS地图图块缓存的方法。 iOS缓存甚至可以在电源循环和iOS设备重启后幸存下来。我过去放大的任何地方都会在之前的测试会话中使用内存中的切片进行渲染。

This functionality is working - but I am having a hard time testing it after each new build because I can't find a way to flush / reset the iOS map tile cache. The iOS cache even survives a power-cycle and reboot of the iOS device. Anywhere I have zoomed into in the past renders with the tiles in memory from the prior test session.

有没有办法强制iOS刷新其地图缓存?现在我能想到的唯一选择是每次我需要进行测试时重新刷新操作系统。

Is there a way to force iOS to flush its map cache? Right now the only alternative I can think of is to reflash the OS every time I need to do a test.

谢谢!

BTW:这几乎与这个问题重复,但在在这种情况下,问题不是使用空缓存进行测试,而是释放内存。那里接受的答案集中在RAM问题上,而不是我在这里遇到的问题。

BTW: This is almost a duplicate of this question, but in that case the issue wasn't testing with an empty cache, but rather freeing up memory. The accepted answer given there focused on the RAM issue, not the same problem that I am having here.

推荐答案

尝试设置 NSURLConnection 在创建 MKMapView的任何实例之前将缓存大小设置为零

    NSURLCache *sharedCache = [[NSURLCache alloc] initWithMemoryCapacity:0 diskCapacity:0 diskPath:nil];
[NSURLCache setSharedURLCache:sharedCache];
[sharedCache release];

这可能会使您的连接停止存储缓存数据,因为缓存剩余大小将始终不足

This might make your connections stop storing cached data as the cache remaining size will always be insufficient

这篇关于如何清除MKMapView的地图图块缓存?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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