【问题标题】:NSLocationAlwaysUsageDescription string added in info.plist is not showing in permission popup ios在 info.plist 中添加的 NSLocationAlwaysUsageDescription 字符串未显示在权限弹出 ios 中
【发布时间】:2016-07-09 04:09:03
【问题描述】:
<key>NSLocationAlwaysUsageDescription</key>
<array>
<string>Location is required to find out where you are</string>
</array>
<key>Privacy-Location Usage Description</key>
<string>Location is required to find out where you are.</string>
我在 info.plist 中添加了这个。权限弹出窗口仍然没有显示添加的字符串,而是显示--
即使您不使用该应用,也允许“应用”访问您的位置?
【问题讨论】:
标签:
ios
cllocationmanager
【解决方案1】:
使用 CLLocationManager
-
在 Info.plist 文件中添加以下行(右键 clic -> 打开为 -> 源代码)
<key>NSLocationAlwaysUsageDescription</key>
<string>Your explanation</string>
-
将 CLLocationManagerDelegate 添加到您的 swift 文件中
class ViewController: UIViewController, CLLocationManagerDelegate {...}
-
在您的 viewDidLoad() 函数中,编写以下行:
var locationManager : CLLocationManager = CLLocationManager()
locationManager.delegate = self
locationManager.requestAlwaysAuthorization()
它应该工作!希望对你有帮助!
【讨论】:
-
嘿,谢谢,开始工作了。我不得不删除 info.plist 中的 标签