Swift 2 – Can't get user location with CLLocationManager

前端 未结 3 952
难免孤独
难免孤独 2020-12-11 22:29

Here is my VC code:

import UIKit
import MapKit
import CoreLocation

class ViewController: UIViewController, MKMapViewDelegate, CLLocationMan         


        
3条回答
  •  星月不相逢
    2020-12-11 22:48

    Try getting the location by getting the last object for the array locations in the method locationManager(_:,didUpdateLocations locations: [CLLocations]) .

    Something like this:

    func locationManager(manager: CLLocationManager, didUpdateLocations locations: [CLLocation]) {
            let locValue:CLLocationCoordinate2D = locations.last!
            print("locations = \(locValue.latitude) \(locValue.longitude)")
    }  
    

提交回复
热议问题