本文转载至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
精华: 0 
发帖: 67
可可豆: 233 CB
威望: 200 点
在线时间: 507(时)
注册时间: 2013-08-28
最后登录: 2015-01-20

 
沙发 :发表于: 2014-12-01 17:16   发自: Web Page

 
 
 
 
NSLocationAlwaysUsageDescription
看了文档,应该是这个key吧 

解决ios8 webView加载的地图无法定位问题的更多相关文章

  1. 安卓 WebView加载本地图片时居中显示

    在一个项目中使用WebView显示gif图片(自定义的View无法放大gif),当图片过小时只在左侧显示,经过研究发现无论设置android:layout_gravity="center_h ...

  2. WebView加载本地html、js文件常见问题及解决办法

    声明:基于android studio平台,php语言搭建服务器 目录: 一.JavaScript脚本语言没有反应 二.alert无法弹出 三.html页面之间不能跳转 四.屏幕缩放没有达到预期效果 ...

  3. 解决WebView加载本地文件乱码

    一.问题描述 这几天现场反馈一些问题,主要是文件浏览有部分文件显示乱码,像这样: 而文件本身又是用WebView加载的,出现有的文件正常有的文件不正常. 二.问题解决 webView 加载主要有:lo ...

  4. WebView加载URL跳转到系统浏览器的解决方法

    1.问题 webview加载url跳转到系统浏览器,用户体验非常的差 2.解决方法 重写WebViewClient的shouldOverrideUrlLoading(WebView view, Str ...

  5. android中webView加载H5,JS不能调用问题的解决

    使用了html5 页面,使用webView加载后发现 超链接的锚点不可以用 为webView设置下面两句就好了: mWebView.getSettings().setDomStorageEnabled ...

  6. WebView加载HTML图片大小自适应与文章自动换行

    http://www.brighttj.com/ios/ios-webview-load-html-image-adaptive.html 在很多App中都会使用到webview,尤其是在加载新闻内容 ...

  7. Android WebView加载本地html并实现Java与JS交互

    最近做的一个项目中,用到自定义地图,将自定义地图转换成html页面,现在需要做的是如何将本地的html加载到android中,并可以实现交互. 相关讲解: 其实webview加载资源的速度并不慢,但是 ...

  8. 【iOS】WebView加载HTML图片大小自适应与文章自动换行

    在很多App中都会使用到webview,尤其是在加载新闻内容等文章形式的数据时.因为图文混编以及不同字体格式的显示,在iOS进行编辑 和显示都是一大问题(当然,iOS中也可以用CoreText进行绘制 ...

  9. iOS webview加载时序和缓存问题总结

    iOS webView的加载时序 UIWebView加载顺序: - (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSU ...

随机推荐

  1. RocketMQ之连接以及连接缓存

    发现rabbitmq有一个ConnectionFactory.发现rocketmq好像没这个东西.按道理来说如果每次发送消息都新建一条连接肯定是不可能的. ps:其实之所以是有上面的疑问是因为数据库连 ...

  2. 微信小程序 - 回到自己位置(map)

    演示效果: 图片资源 index.js /** * 回到自己位置,在cover-image上绑定点击事件即可. */ clickcontrol(e) { let mpCtx = wx.createMa ...

  3. 用聚合数据API(苏州实时公交API)快速写出小程序

    利用聚合数据API快速写出小程序,过程简单. 1.申请小程序账号 2.进入开发 3.调用API.比如“苏州实时公交”小程序,选择的是苏州实时公交API. 苏州实时公交API文档:https://www ...

  4. Oracle 和sqlserver 字符串补齐

    Oracle:Lpad函数 语法格式如下: lpad( string, padded_length, [ pad_string ] ) string 准备被填充的字符串: padded_length ...

  5. zabbix监控redis的key值

    配置zabbix客户端配置文件 vim /etc/zabbix/zabbix_agentd.conf 添加  Include=/etc/zabbix/zabbix_agentd.d/ 添加脚本对red ...

  6. 锁定窗口,禁止更新的win32函数

    [DllImport("user32.dll", EntryPoint = "LockWindowUpdate", SetLastError = true, E ...

  7. cordova开发自己定义插件

    以下是自己定义cordova插件的基本入门.做插件的小白可以參考一下哈,兴许会更新插件的进阶博客,希望大家可以共同学习共同进步 1.环境搭建 cordova插件开发前须要安装一些软件和配置环境 1.1 ...

  8. robot.txt 文件 作用和语法

    seo工作者应该不陌生,robots.txt文件是每一个搜索引擎蜘蛛到你的网站之后要寻找和访问的第一个文件,robots.txt是你对搜索引擎制定的一个如何索引你的网站的规则.通过该文件,搜索引擎就可 ...

  9. C# Post Json数据到对方url

    1. /// <summary> /// 调用对方Url,Post上传数据 /// </summary> /// <param name="postData&q ...

  10. eclipse代码凝视之模板xml

    曾经在eclipse中配置凝视的时候,都是各自在自己电脑上配置凝视,每一个同事风格不一样,并且配置繁琐.假设新来的同事忘了提醒,可能就没有配置凝视了.所以我就把类.方法的凝视写成xml文件.然后将配置 ...