小编Far*_*rgo的帖子

应用程序的Info.plist必须包含NSLocationWhenInUseUsageDescription键,该键具有字符串值,向用户解释该应用程序如何使用此数据

我是IOS的新手。我正在尝试使用地图获取用户的当前位置。我正在关注的教程适用于IOS 10。

我仔细阅读了这篇文章并做了所有说明,但仍然无法正常工作 位置服务在iOS 11中无法正常工作

以下是我的代码

class ViewController: UIViewController,CLLocationManagerDelegate,MKMapViewDelegate {

    var locationManager=CLLocationManager()
    // @IBOutlet weak var mapView: MKMapView!
    @IBOutlet weak var mapView: MKMapView!

    override func viewDidLoad() {
        super.viewDidLoad()
        // Do any additional setup after loading the view, typically from a nib.

        locationManager.delegate=self
        locationManager.desiredAccuracy=kCLLocationAccuracyBest
        locationManager.requestWhenInUseAuthorization()
        locationManager.startUpdatingLocation()
    }

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }

    func locationManager(_ manager: CLLocationManager, didUpdateLocations locations: [CLLocation]) {
        let userLocation:CLLocation = locations[0]
        let latitude=userLocation.coordinate.latitude
        let longitude=userLocation.coordinate.longitude
        let latDelta:CLLocationDegrees=0.05
        let …
Run Code Online (Sandbox Code Playgroud)

maps swift ios11

3
推荐指数
1
解决办法
9541
查看次数

标签 统计

ios11 ×1

maps ×1

swift ×1