gpt4 book ai didi

ios - 从 Storyboard添加 GMSMapView 时获取 nil

转载 作者:行者123 更新时间:2023-11-30 13:01:54 24 4
gpt4 key购买 nike

我决定在 Storyboard中创建一个 View ,并将其类定义为 GMSMapView。然后我为我的 ViewController 类创建了一个 IBOutlet

但是当我尝试将相机添加到我的 GMSMapView 时,我在 IBOutlet 对象中得到一个 nil 值:

let camera: GMSCameraPosition = GMSCameraPosition.camera(withLatitude: 48.857165, longitude: 2.354613, zoom: 8.0)
newMapView.camera = camera

发生了什么事?

最佳答案

试试这个代码..

var mapView_: GMSMapView!
var camera = GMSCameraPosition.camera(withLatitude: centerLat, longitude: centerLng, zoom: centerZoom)
mapView_ = GMSMapView.map(withFrame: self.allplacemapview.bounds, camera: camera)
mapView_.mapType = kGMSTypeNormal
var startLoc = CLLocationCoordinate2DMake(theAppDelegate.lang, theAppDelegate.long1)
self.setMarker(mapView_, imageName: "startPoint.png", location: startLoc, titleString: "Current Location")
self.allplacemapview.addSubview(mapView_)

关于ios - 从 Storyboard添加 GMSMapView 时获取 nil,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39824161/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com