首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >RMTileCache后台缓存永远不会达到totalTiles计数,也永远不会告诉委托它已经完成

RMTileCache后台缓存永远不会达到totalTiles计数,也永远不会告诉委托它已经完成
EN

Stack Overflow用户
提问于 2014-03-10 22:55:08
回答 1查看 489关注 0票数 0

我正在使用MapBox和RMTileCache的beginBackgroundCacheForTileSource:在我的客户端应用程序中渲染地图之前预先加载tiles。我想为地图上当前可见的区域预加载从缩放级别3到缩放级别7的瓦片。因此,我使用从mapView latitudeLongitudeBoundingBox返回的mapView传递当前的边界。我的ViewController实现了RMTileCacheBackgroundDelegate,以便在缓存发生后完成时获得回调。我确实收到了didBeginBackgroundCacheWithCount:forTileSource:和didBackgroundCacheTile:withIndex:ofTotalTileCount:上的回调,但是,从来没有调用过tileCacheDidFinishBackgroundCache:。

我浏览了RMTileCache的源代码,注意到"progTile“中缓存的磁贴的实际数量从未达到"totalTiles”中计算出的总数量。因此,没有到达最终的回调tileCacheDidFinishBackgroundCache:。

我不确定如何更改(或者是否应该更改) totalTiles计算。也许我在最初的调用中传递了错误的视图rect?我不完全清楚这是否正确。我可以创建一个简单的修复程序,调用tileCacheDidFinishBackgroundCache:在缓存简单完成的情况下,但这似乎只是隐藏了问题。这里的任何指导都将不胜感激。

作为参考,我的测试代码很简单:

代码语言:javascript
复制
#import "ViewController.h"

@interface ViewController ()

@end

@implementation ViewController

- (void)viewDidLoad
{
    [super viewDidLoad];

    RMMapboxSource *onlineSource = [[RMMapboxSource alloc] initWithMapID:@"appleweed.control-room"];
    mapView = [[RMMapView alloc] initWithFrame:self.view.bounds andTilesource:onlineSource];
    //mapView.delegate = self;
    mapView.bouncingEnabled = YES;
    mapView.clusteringEnabled = YES;
    mapView.clusterMarkerSize = CGSizeMake(40, 40);
    mapView.clusterAreaSize = CGSizeMake(40, 40);
    mapView.zoom = 1;

    RMSphericalTrapezium rect = [mapView latitudeLongitudeBoundingBox];
    mapView.tileCache.backgroundCacheDelegate = self;
    [mapView.tileCache beginBackgroundCacheForTileSource:mapView.tileSource
    southWest:rect.southWest
    northEast:rect.northEast
    minZoom:3.0
    maxZoom:7.0];

}

- (void)tileCache:(RMTileCache *)tileCache didBeginBackgroundCacheWithCount:(int)tileCount forTileSource:(id <RMTileSource>)tileSource {

    NSLog(@"start");

}

- (void)tileCache:(RMTileCache *)tileCache didBackgroundCacheTile:(RMTile)tile withIndex:(int)tileIndex ofTotalTileCount:(int)totalTileCount {

   // float percentComplete = ((float)tileIndex / (float)totalTileCount) * 100;
    //NSString *update = [NSString stringWithFormat:@"%.0f%%", percentComplete];
    //NSLog(@"%@",update);

}

- (void)tileCacheDidFinishBackgroundCache:(RMTileCache *)tileCache {

    NSLog(@"DONE!");

}

- (void)tileCacheDidCancelBackgroundCache:(RMTileCache *)tileCache {

    NSLog(@"Canceled!");

}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end
EN

回答 1

Stack Overflow用户

发布于 2014-03-11 04:25:58

它是否每次都在相同的瓦片计数处停止?是否有地图视图同时可见?如果你在调试器中暂停你的应用程序,一旦它在后台似乎停止了下载磁贴,它会做什么?

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/22303592

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档