在iOS 11和Xcode 9.1中没有调用CLLocationManager的didUpdateLocations委托[重复]

问题描述 投票:0回答:1

这个问题在这里已有答案:

您必须获取设备当前位置,为此我使用CLLocationManager类但didUpdateLocations没有调用。

我是

我的代码和plist如下:

enter image description here

enter image description here

enter image description here

enter image description here

ios swift cllocationmanager cllocation
1个回答
1
投票
<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()
© www.soinside.com 2019 - 2024. All rights reserved.