出現錯誤,我一直在搜索如何將Corelocation和GoogleMaps一起使用。當我在代碼的GMScameraposition部分發生錯誤時,我以爲我已經擁有它了。基本上我試圖讓我的位置加載視圖這就是爲什麼大多數在viewdidload()。構建地圖應用程序致命錯誤ios
import UIKit
import GoogleMaps
import CoreLocation
class ViewController: UIViewController, CLLocationManagerDelegate {
var locationManager: CLLocationManager!
var currentLocation: CLLocation!
var long: Float64!
var lat: Float64!
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
locationManager = CLLocationManager()
locationManager.delegate = self;
locationManager.desiredAccuracy = kCLLocationAccuracyBest
locationManager.requestAlwaysAuthorization()
locationManager.startUpdatingLocation()
let camera = GMSCameraPosition.cameraWithLatitude(lat,
longitude: long, zoom:6)
let mapView = GMSMapView.mapWithFrame(CGRectZero, camera:camera)
let marker = GMSMarker()
marker.position = camera.target
marker.snippet = "Hello World"
marker.appearAnimation = kGMSMarkerAnimationPop
marker.map = mapView
self.view = mapView
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
func locationManager(manager: CLLocationManager, didUpdateLocations locations: [CLLocation]) {
currentLocation = locations.last! as CLLocation
long = currentLocation.coordinate.longitude;
lat = currentLocation.coordinate.latitude;
}
}
你得到了什麼錯誤?請不要讓我們猜測。 – Jonah
對不起,不提。 「exc_bad_instruction(code = exc_i386_invop subcode = 0x0)」這是當我嘗試構建 –
時出現在我看來進一步陷入錯誤,我認爲它的「長」和「拉特」變量沒有一個值,然後被傳遞給GMSCameraPosition –