在 iOS 11 和 Xcode 9.1 中未调用 CLLocationManager 的 didUpdateLocations 委托

didUpdateLocations delegate of CLLocationManager is not called in iOS 11 and Xcode 9.1

你好必须获取设备当前位置,为此我正在使用 CLLocationManager class 但没有调用 didUpdateLocations。

我是

我的代码和plist如下:

<key>NSLocationAlwaysUsageDescription</key>
    <string>Requires GPS to track persons</string>
    <key>NSLocationAlwaysAndWhenInUseUsageDescription</key>
    <string>Requires GPS to track persons</string>
    <key>NSLocationWhenInUseUsageDescription</key>
    <string>Requires GPS to track persons</string>
    <key>UIBackgroundModes</key>
    <array>
        <string>fetch</string>
        <string>location</string>
    </array>

在 viewdidLoad 中添加这个

locationManager.delegate = self
   self.locationManager.allowsBackgroundLocationUpdates = true
   self.locationManager.startUpdatingLocation()