解决ios8 webView加载的地图无法定位问题

  本文转载至http://www.cocoachina.com/bbs/read.php?tid-237825.html

 
 
1.在文件info.pilist 中导入 NSLocationWhenInUseUsageDescription

//IOS8新功能用户开启定位 
2.appDelegate中带入 #import<CoreLocation/CoreLocation.h>


3.加入下面的语句
 CLLocationManager* location = [CLLocationManager new];
 [location requestAlwaysAuthorization]; 


再次运行软件就可以定位了。 
原因如下:
scussion:
 *      When +authorizationStatus == kCLAuthorizationStatusNotDetermined,
 *      calling this method will trigger a prompt to request "always"
 *      authorization from the user.  If possible, perform this call in response
 *      to direct user request for a location-based service so that the reason
 *      for the prompt will be clear.  Any authorization change as a result of
 *      the prompt will be reflected via the usual delegate callback:
 *      -locationManager:didChangeAuthorizationStatus:.
 *
 *      If received, "always" authorization grants access to the user's
 *      location via any CLLocationManager API, and grants access to
 *      launch-capable monitoring API such as geofencing/region monitoring,
 *      significante location visits, etc.  Even if killed by the user, launch
 *      events triggered by monitored regions or visit patterns will cause a
 *      relaunch.
 *
 *      "Always" authorization presents a significant risk to user privacy, and
 *      as such requesting it is discouraged unless background launch behavior
 *      is genuinely required.  Do not call +requestAlwaysAuthorization unless
 *      you think users will thank you for doing so.
 *
 *      When +authorizationStatus != kCLAuthorizationStatusNotDetermined, (ie
 *      generally after the first call) this method will do nothing.
 *
 *      If the NSLocationAlwaysUsageDescription key is not specified in your
 *      Info.plist, this method will do nothing, as your app will be assumed not
 *      to support Always authorization.



大概意思就是说:IOS8 新增加了一个选项 ,如果要开启定位这个隐私选项的话 需要在Pilist导入NSLocationWhenInUseUsageDescription,然后掉用 requestAlwaysAuthorization这个方法。 此方法执行后,当要执行定位功能的时候就会触发一个询问,询问用户是否使用定位功能,如果选择是,则启动定位功能,如果选择否,则方法返回,下次还将继续询问用户。

 
 
 
 

 
级别: 侠客
 
UID: 239860
精华: 
发帖: 67
可可豆: 233 CB
威望: 200 点
在线时间: 507(时)
注册时间: 2013-08-28
最后登录: 2015-01-20
 
沙发 :发表于: 2014-12-01 17:16   发自: Web Page
 
 
 
 
NSLocationAlwaysUsageDescription
看了文档,应该是这个key吧 
posted @ 2015-01-21 23:54  天牛  阅读(525)  评论(0编辑  收藏  举报