Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/swift/20.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 谷歌地图SDK(GMSMapView)与Swift崩溃_Ios_Swift_Google Maps - Fatal编程技术网

Ios 谷歌地图SDK(GMSMapView)与Swift崩溃

Ios 谷歌地图SDK(GMSMapView)与Swift崩溃,ios,swift,google-maps,Ios,Swift,Google Maps,我添加了带有pods的GoogleMap SDK,它位于Objective-C中 我在Swift项目中使用桥头 在appdelegate中,我使用此代码提供api密钥 GoogleMapsService.provideAPIKey(kGooglePlacesApiKey) // where kGooglePlacesApiKey is the key generated on google console. 在ViewController中,我使用下面的代码添加Google地图 func ad

我添加了带有pods的GoogleMap SDK,它位于
Objective-C

我在
Swift
项目中使用桥头

在appdelegate中,我使用此代码提供api密钥

GoogleMapsService.provideAPIKey(kGooglePlacesApiKey)
// where kGooglePlacesApiKey is the key generated on google console.
在ViewController中,我使用下面的代码添加Google地图

func addGoogleMap()
{
    let camera = GMSCameraPosition.cameraWithLatitude(51.5074,
                                                      longitude: 0.1278, zoom: 10)
    mapView = GMSMapView.mapWithFrame(CGRectMake(0, 157, self.view.frame.size.width, self.view.frame.size.height - 206.1), camera:
        camera)
    mapView.myLocationEnabled = true
    mapView.delegate = self
    self.view .addSubview(mapView)
}
当我尝试创建
GMSMapView的对象时,它总是在这一行崩溃:

mapView = GMSMapView.mapWithFrame(CGRectMake(0, 157, self.view.frame.size.width, self.view.frame.size.height - 206.1), camera:
        camera)
它没有给出任何错误日志,只是切换到appdelegate并以红色显示错误


创建一个CGRect,将所需的框架设置为mapview框架

var gframe = CGRectMake(0, 157, self.view.frame.size.width, self.view.frame.size.height - 206.1)

        mapView = GMSMapView.mapWithFrame(gframe, camera:camera)

创建一个CGRect,将所需的框架设置为mapview框架

var gframe = CGRectMake(0, 157, self.view.frame.size.width, self.view.frame.size.height - 206.1)

        mapView = GMSMapView.mapWithFrame(gframe, camera:camera)