2016-10-03 3 views
0

私はストーリーボードにビューを作成し、そのクラスをGMSMapViewに定義しました。それから私はViewControllerクラスにIBOutletを作成しました。何が起こっているストーリーボードからGMSMapViewを追加するときにnilを取得する

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

:私は私のGMSMapViewにカメラを追加しようとする

はしかし、私はIBOutletオブジェクト内のnilの値を取得していますか?

+1

をこのコードを試してみてください? viewDidLoadに書き込んでみてください。コンセントは、アクセスするまで設定されていない場合があります。 – PGDev

+0

私はそれを私の 'viewDidLoad'に書いています –

+0

@JaysonTamayoあなたのコードを磨くことができますか? –

答えて

0

は..あなたはこのコードを書いている

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_) 
+0

var mapView_:GMSMapView! VARカメラ= GMSCameraPosition.camera(withLatitude:centerLat、経度:centerLng、ズーム:centerZoom) mapView_ = GMSMapView.map(withFrame:self.allplacemapview.bounds、カメラ:カメラ) mapView_.mapType = kGMSTypeNormal VAR startLoc = CLLocationCoordinate2DMake (mapView_、imageName: "startPoint.png"、location:startLoc、titleString: "現在の場所") self.allplacemapview.addSubview –

関連する問題