• 解决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吧 
  • 相关阅读:
    no.5.print sum
    0.1 hint crack
    no.4 抽奖测试
    no2.crossdomain.xml批量读取(待完善)
    no.1
    day7-读写分离
    day6-主从
    day5-备份
    day4-用户授权
    Day3-体系结构+查询+导入/出
  • 原文地址:https://www.cnblogs.com/Camier-myNiuer/p/4240473.html
Copyright © 2020-2023  润新知