問題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。