问题:iOS 11 定位问题

来源:互联网 发布:手机淘宝在哪输入口令 编辑:程序博客网 时间:2024/05/22 06:41

问题1:

iOS11 定位权限未通过,控制台输出以下信息:

This app has attempted to access privacy-sensitive data without a
usage description. The app’s Info.plist must contain both
NSLocationAlwaysAndWhenInUseUsageDescription and
NSLocationWhenInUseUsageDescription keys with string values explaining
to the user how the app uses this data

解决方法:

在 info.plist 文件添加一个 NSLocationAlwaysAndWhenInUseUsageDescription 和 NSLocationWhenInUseUsageDescription 的 key,然后添加描述。

问题2:

定位失败,方法locationManager: didFailWithError:打印error为:

Error Domain=kCLErrorDomain Code=0 “(null)”

解决方法:

只要去Product -> Scheme -> Edit Scheme -> Options -> 把“ Allow Location Simulation ” 选项选中,并且设置下方的“default location”就可以了,不要让这个选项为none。

原创粉丝点击