Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/amazon-s3/2.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
Ios MkMapView取消加载google互动程序_Ios_Mkmapview - Fatal编程技术网

Ios MkMapView取消加载google互动程序

Ios MkMapView取消加载google互动程序,ios,mkmapview,Ios,Mkmapview,我有一个案例,需要在MkMapView顶部导入一个覆盖贴图。 覆盖层完全覆盖了下面的谷歌贴片,因此不需要加载,而且会增加应用程序的开销 有没有办法告诉mkMapView停止加载互动程序?据我所知,您无法阻止mkMapView加载谷歌地图互动程序,如果你的应用程序在显示 MkMaveVIEW/COD>时覆盖了谷歌徽标,那么你可能会被拒绝。你可能想考虑编写一个自定义的代码> UISCLOCVIEW 来显示你的地图。p> 我遇到了一个相关的问题,但在我的例子中,我的覆盖并没有覆盖所有的谷歌瓷砖。 如果

我有一个案例,需要在MkMapView顶部导入一个覆盖贴图。 覆盖层完全覆盖了下面的谷歌贴片,因此不需要加载,而且会增加应用程序的开销


有没有办法告诉mkMapView停止加载互动程序?

据我所知,您无法阻止
mkMapView
加载谷歌地图互动程序,如果你的应用程序在显示<代码> MkMaveVIEW/COD>时覆盖了谷歌徽标,那么你可能会被拒绝。你可能想考虑编写一个自定义的代码> UISCLOCVIEW 来显示你的地图。p> 我遇到了一个相关的问题,但在我的例子中,我的覆盖并没有覆盖所有的谷歌瓷砖。 如果有人有这个问题,并试图停止加载谷歌瓷砖,我设法将一个灰色瓷砖(256x256)覆盖在谷歌地图瓷砖上。 要执行此操作,顶层互动程序必须 /FakeTiles/1/1/0.png并将此目录添加到项目的资源中。 (注意:不要将此拖动到“项目>添加文件>文件夹>为任何文件夹创建文件夹引用”中)

然后添加自定义平铺覆盖

然后您需要此代码来缩放灰色瓷砖

实际上,有两种方法可以实现真正的“隐藏Google tiles”方法(johndope解决方案仅在其上放置一个覆盖层,但不阻止加载tiles)

请注意,下面描述的选项1可能会导致您的应用程序被拒绝,而选项2则不会,但会稍微复杂一些

公共部分:检索
MKMapTileView
对象

if ( [mkTiles respondsToSelector:@selector(setDrawingEnabled:)])
    [mkTiles performSelector:@selector(setDrawingEnabled:) withObject:(id)NO];
在每个
MKMapView
中都有一个类型为
MKMapTileView
的未记录类。检索它不是拒绝的理由。在此代码中,
MKMapView
实例将被称为
mapView

UIView* scrollview = [[[[mapView subviews] objectAtIndex:0] subviews] objectAtIndex:0];
UIView* mkTiles = [[scrollview subviews] objectAtIndex:0]; // <- MKMapTileView instance
这将防止在
MKMapTileView
实例上调用未记录的方法
setDrawingEnabled

选项2:方法旋转

if ( [mkTiles respondsToSelector:@selector(setDrawingEnabled:)])
    [mkTiles performSelector:@selector(setDrawingEnabled:) withObject:(id)NO];
在控制器实现之外,您将编写如下内容:

// Import runtime.h to unleash the power of objective C 
#import <objc/runtime.h>

// this will hold the old drawLayer:inContext: implementation
static void (*_origDrawLayerInContext)(id, SEL, CALayer*, CGContextRef);

// this will override the drawLayer:inContext: method
static void OverrideDrawLayerInContext(UIView *self, SEL _cmd, CALayer *layer, CGContextRef context)
{
    // uncommenting this next line will still perform the old behavior
    //_origDrawLayerInContext(self, _cmd, layer, context);

    // change colors if needed so that you don't have a black background
    layer.backgroundColor = RGB(35, 160, 211).CGColor;

    CGContextSetRGBFillColor(context, 35/255.0f, 160/255.0f, 211/255.0f, 1.0f);
    CGContextFillRect(context, layer.bounds);
}

希望这对任何人都有帮助,这段代码最初是在这里描述的。

上述方法是否也阻止了Tile的下载?对于这两种方法,我的答案都是否定的,可能不是。似乎苹果已经改变了ios10中的实现_MKMapLayerHostingView
// Retrieve original method object
Method  origMethod = class_getInstanceMethod([mkTiles class], 
                                             @selector(drawLayer:inContext:));

// from this method, retrieve its implementation (actual work done)
_origDrawLayerInContext = (void *)method_getImplementation(origMethod);

// override this method with the one you created    
if(!class_addMethod([mkTiles class],
                    @selector(drawLayer:inContext:), 
                    (IMP)OverrideDrawLayerInContext,
                    method_getTypeEncoding(origMethod)))
{
    method_setImplementation(origMethod, (IMP)OverrideDrawLayerInContext);
}