我开发了地图应用程序,并考虑在iOS7中为MKTileOverlay和MKTileOverlayRenderer使用新的函数。但我在谷歌上搜索时运气不佳。
我找到了这个线程,告诉我做MKTileOverlay子类
Hiding mapview when mapoverlay is visible 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]是load tileData,但是如何将tileData保存到DB?
如果我能从数据库中获得tileData,result(tile, nil);就足以让覆盖显示出来吗?或者我需要在覆盖loadTileAtPath:result:之后做一些其他的事情
谢谢
发布于 2013-12-25 09:59:55
对不起,我问了一个愚蠢的问题,现在我想我对这个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);
}
}可能是环顾四周一天,使我目瞪口呆,无法理解它的图书馆,对不起,并希望这可能会帮助谁面临同样的问题。
https://stackoverflow.com/questions/20771273
复制相似问题