Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/95.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/clojure/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
iOS8中损坏的MapKit磁贴覆盖_Ios_Objective C_Ios8_Mapkit_Openstreetmap - Fatal编程技术网

iOS8中损坏的MapKit磁贴覆盖

iOS8中损坏的MapKit磁贴覆盖,ios,objective-c,ios8,mapkit,openstreetmap,Ios,Objective C,Ios8,Mapkit,Openstreetmap,我有以下代码在我的应用程序中实现OSM,而不是默认的Apple one: dispatch_async(dispatch_get_main_queue(), ^{ NSString *template = @"http://tile.openstreetmap.org/{z}/{x}/{y}.png"; MKTileOverlay *overlay = [[MKTileOverlay alloc] initWithURLTemplate:template]; overla

我有以下代码在我的应用程序中实现OSM,而不是默认的Apple one:

dispatch_async(dispatch_get_main_queue(), ^{
    NSString *template = @"http://tile.openstreetmap.org/{z}/{x}/{y}.png";
    MKTileOverlay *overlay = [[MKTileOverlay alloc] initWithURLTemplate:template];
    overlay.canReplaceMapContent = YES;
    [self.mapView addOverlay:overlay level:MKOverlayLevelAboveLabels];});
以及:


但这似乎无法解决问题。

您正在使用的代码看起来不错,除了

在块中添加覆盖看起来很奇怪。我只是添加了一个动作,它似乎根本不会挂起UI

只要做

    NSString *template = @"http://tile.openstreetmap.org/{z}/{x}/{y}.png";
    MKTileOverlay *overlay = [[MKTileOverlay alloc] initWithURLTemplate:template];
    overlay.canReplaceMapContent = YES;
    [self.mapView addOverlay:overlay level:MKOverlayLevelAboveLabels];
另外,我向苹果提交了一个bug,当他们想要一个样本时,我的覆盖图不会显示……直到我设置了代理。(尽管我对故事板很感兴趣)。苹果关闭了我的bug作为复制品,这样他们就知道了

mapView.delegate = self

您的地图视图代理是否仍处于设置状态?当然。我没有更改此部分。我的应用程序开始执行相同的操作。它不会崩溃;对于似乎呈现的每个贴图块,都会显示大量错误消息。但它仍然不会呈现内容。我会添加一个调试行,以确保1)您获得的是有效的贴图块URL,2)返回的图像是有效的。这听起来像是引擎盖下的核心图形例程正在试图绘制您的瓷砖,它们被来自OSM的数据阻塞了。
dispatch_queue_t fetchTiles = dispatch_queue_create("fetcher", NULL);
dispatch_async(fetchTiles, ^{
    NSString *template = @"http://tile.openstreetmap.org/{z}/{x}/{y}.png";
    MKTileOverlay *overlay = [[MKTileOverlay alloc] initWithURLTemplate:template];
    overlay.canReplaceMapContent = YES;
    dispatch_async(dispatch_get_main_queue(), ^{
        [self.mapView addOverlay:overlay level:MKOverlayLevelAboveLabels];});});
    NSString *template = @"http://tile.openstreetmap.org/{z}/{x}/{y}.png";
    MKTileOverlay *overlay = [[MKTileOverlay alloc] initWithURLTemplate:template];
    overlay.canReplaceMapContent = YES;
    [self.mapView addOverlay:overlay level:MKOverlayLevelAboveLabels];
mapView.delegate = self