0

我正在开发地图应用程序并考虑在 iOS7 中为 MKTileOverlay 和 MKTileOverlayRenderer 使用新功能。但我用谷歌搜索没有运气。

我找到了这个线程,告诉我做子类化 MKTileOverlay

当mapoverlay可见时隐藏mapview ios7

来自线程的代码:

-(void)loadTileAtPath:(MKTileOverlayPath)path result:(void (^)(NSData *, NSError *))result
{
    NSData *tile = [self someHowGetTileImageIntoNSDataBaseOnPath:path];
    if (tile) {
        result(tile, nil);
    } else {
        result(nil, [NSError errorWithDomain: CUSTOM_ERROR_DOMAIN code: 1 userInfo:nil]);
    }
}

问题是: [self someHowGetTileImageIntoNSDataBaseOnPath:path]加载 tileData 但如何将 tileData 保存到数据库?

如果我可以从数据库中获取 tileDataresult(tile, nil);是否足以显示覆盖?或者我需要在覆盖后做其他事情loadTileAtPath:result:

谢谢

4

1 回答 1

0

I sorry for asking stupid question, Now I think I understand more about this MKTileOverlay.

-(void)loadTileAtPath:(MKTileOverlayPath)path result:(void (^)(NSData *, NSError *))result
{
    NSData *tile = [self someHowGetTileImageIntoNSDataBaseOnPath:path];
    if (tile) {
        result(tile, nil);
    } else {
        NSHTTPURLResponse *response = nil;
        NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[self URLForTilePath:path]];
        //Or you can using asynchronous request.
        NSData *tileData = [NSURLConnection sendSynchronousRequest:request returningResponse:&response error:nil];
        [self saveCachedWithData:tileData];
        result(tileData, nil);
    }
}

May be looking around for a day make me stun and cannot understand it's library, Sorry again and hope this may help someone who face same problem.

于 2013-12-25T09:59:55.553 回答