【问题标题】:New GMSMapView not working, but old GMSMapView loading properly新 GMSMapView 不工作,但旧 GMSMapView 正确加载
【发布时间】:2017-02-20 20:09:56
【问题描述】:

当我创建一个新的 GMSMapView 时,它不会加载。我的项目中有其他 GMSMapViews 可以正确加载。我正在使用情节提要编辑器将 GMSMapView 的自定义子类分配给 UIView。为什么新的不起作用?

【问题讨论】:

    标签: ios swift google-maps gmsmapview


    【解决方案1】:

    我通过查看我的故事板文件的源代码找到了解决此问题的方法。

    我的旧 GMSMapViews 看起来像这样:

    <view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" 
          id="hbm-BT-3Ow" customClass="GMSMapView">
    

    我的新的看起来像这样:

    <view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" 
          id="alb-9Z-Vu8" customClass="GMSMapView" 
          customModule="{My Project Name}" customModuleProvider="target">
    

    当我为新 UIView 将自定义类设置为 GMSMapView 时,关联的模块是“我的项目”而不是以前的“无”。

    问题是我在我的项目中为 GMSMapView 创建了一个自定义扩展。

    extension GMSMapView {
    
        var visibleBounds: GMSCoordinateBounds {
            return GMSCoordinateBounds(region: self.projection.visibleRegion())
        }
    }
    

    解决方法:

    extension GMSMapView 更改为extension GoogleMaps.GMSMapView 解决了我的问题。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-05-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-11-29
      • 1970-01-01
      相关资源
      最近更新 更多