1
我已經添加了帶有pod的GoogleMap SDK,它位於Objective-C
中。GoogleMapSDK(GMSMapView)與Swift崩潰
我正在使用bridge-header在Swift
項目中使用。
在的appdelegate我使用這個代碼提供API密鑰
GoogleMapsService.provideAPIKey(kGooglePlacesApiKey)
// where kGooglePlacesApiKey is the key generated on google console.
在視圖控制器我使用下面的代碼添加谷歌地圖
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)
而且它沒有給予任何埃羅r日誌,它只是切換到appdelegate並顯示紅色錯誤。