【问题标题】:Swift: My Google Maps View isn't showing up斯威夫特:我的谷歌地图视图没有出现
【发布时间】:2015-07-17 21:12:47
【问题描述】:

我第一次尝试在我的 iOS 应用中实现 Google Maps SDK。遵循谷歌的教程后,谷歌地图仍然没有出现在我的视野中。

这是我的 AppDelegate 代码:

func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
    // Override point for customization after application launch.
    GMSServices.provideAPIKey("\(myAPIKey)")
    return true
}

这是我的视图控制器中的代码,直接来自 Google:

var camera = GMSCameraPosition.cameraWithLatitude(-33.86,
        longitude: 151.20, zoom: 6)
    var mapView = GMSMapView.mapWithFrame(CGRectZero, camera: camera)
    mapView.myLocationEnabled = true
    mapsView = mapView

    var marker = GMSMarker()
    marker.position = CLLocationCoordinate2DMake(-33.86, 151.20)
    marker.title = "Sydney"
    marker.snippet = "Australia"
    marker.map = mapView

但是,视图仍然没有显示。我检查了我的 IBOutlet 的视图 - mapsView - 它是正确的。这是我的故事板的图像:

概述的空视图是我的地图视图。但这里是我的应用程序运行时的样子:

【问题讨论】:

    标签: ios uiview google-maps-sdk-ios


    【解决方案1】:

    将视图的自定义类更改为 Storyboard 中的 GMSMapView 而不是 UIView。

    【讨论】:

    • 这个细节很简单很容易忘记
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2015-09-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-06-28
    • 2018-02-10
    相关资源
    最近更新 更多