问题:
一个应用工程,升级ios8后,定位失效了,从网上查找资料,并按照调整步骤,一步一步做完,但是真机运行,总是返回kCLAuthorizationStatusNotDetermined,导致没有授权弹框显示,无法定位
分析:
1. 新建一个测试定位的工程,将定位步骤重新做一遍,定位相关代码一样,奇怪的是,用测试定位工程测试,定位功能是可以正常使用的。
2. 参考http://stackoverflow.com/questions/26000231/ios-8-not-requesting-location-permission,修改调整设置中定位相关设置,问题依旧;复原手机设置,问题依旧。貌似不是手机定位设置问题。
解决:
从结果看,是info.plist相关的设置貌似没有成功。对照新建测试工程和应用工程,终于发现了问题。新建测试工程info.plist里面添加 NSLocationWhenInUseUsageDescription / NSLocationAlwaysUsageDescription时,工程中的info设置中的Custom iOS Target Proterties列表会自动更新;但是应用工程info.plist里面添加 NSLocationWhenInUseUsageDescription / NSLocationAlwaysUsageDescription时,工程中的info设置中的Custom iOS Target Proterties列表不会自动更新,需要手动再添加一次。如下图所示:
参考:
http://blog.csdn.net/kefeng_chen/article/details/42970203
http://ju.outofmemory.cn/entry/125842
http://stackoverflow.com/questions/24062509/location-services-not-working-in-ios-8#comment47155921_24062509
http://nevan.net/2014/09/core-location-manager-changes-in-ios-8/
http://stackoverflow.com/questions/25916841/cllocationmanager-startupdatinglocation-not-calling-locationmanagerdidupdateloc
https://developer.apple.com/library/prerelease/ios/samplecode/LocateMe/Introduction/Intro.html
http://blog.csdn.net/yiyunhzy/article/details/41049721
http://my.oschina.net/u/1418722/blog/318751
https://developer.apple.com/library/ios/documentation/CoreLocation/Reference/CLLocationManager_Class/index.html
https://www.shinobicontrols.com/blog/posts/2014/10/16/ios8-day-by-day-day-34-corelocation-authorization
http://stackoverflow.com/questions/26000231/ios-8-not-requesting-location-permission
http://stackoverflow.com/questions/25188965/ios8-location-how-should-one-request-always-authorization-after-user-has-grante
http://stackoverflow.com/questions/4891950/how-can-i-prompt-the-user-to-turn-on-location-services-after-user-has-denied-the/25296637#25296637
https://imethan.com/2015/01/23/guan-yu-ios-8-corelocation-de-xie-xi-jie/
http://www.unfish.net/archives/834-20140708.html
http://blog.csdn.net/capacity_bo/article/details/42775049