本文转载至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. TreeView 拖拽 增删改

    using Endv.Tools; using System; using System.Data; using System.Drawing; using System.IO; using Syst ...

  2. B11:解释器模式 Iterpreter

    给定一个语言,定义它的文法的一种表示,并定义一个解释器,这个解释器使用该表示来解释语言中的句子. UML: 示例代码: abstract class Expression { abstract pub ...

  3. jQuery-DesktopGrid

    jQueryDesktopGrid jQueryDesktopGrid migrate to https://github.com/jelly-liu/jquery-osx jQuery deskto ...

  4. lodash _.size

    返回collection(集合)的长度,如果集合是类数组或字符串,返回其 length :如果集合是对象,返回其可枚举属性的个数. _.size([1, 2, 3]); // => 3 _.si ...

  5. 挖一挖C#中那些我们不经常使用的东西之系列(1)——ToDictionary,ToLookup

    这个系列我们看看C#中有哪些我们知道.可是又不知道怎么用.又或者懒得去了解的东西,比方这篇我们要介绍的toDictionary 和ToLookup. 从图中我们看到有四个ToXXX的方法,当中ToAr ...

  6. Problem-1000:A + B Problem

    Problem-1000:A + B Problem Sample Code: C 代码: [code] #include int main() { int a,b; while(~scanf(&qu ...

  7. webpack 环境搭建基础框架

    一.安装babel相关 1,安装依赖 cnpm i -D babel-core babel-loader babel-preset-env babel-preset-stage- babel-plug ...

  8. chrome 一进入调试页面就会自己主动打断点

    近期在用chrome调试页面时.一刷新页面总会自己主动打断点.自己鼓捣了一下,发现 把它改为这个样子的时候就能够解决问题,即把调试面板上的第5个button从Deactivate breakpoint ...

  9. centos7下安装mysql5.7和jdk 1.8

    安装mysql5.7 具体安装过程可参见官网:A Quick Guide to Using the MySQL Yum Repository 进入/usr/local/src文件夹. cd /usr/ ...

  10. scp命令的用法

    用法: scp 命令 scp 能够在 2个 linux 主机间拷贝文件: 命令基本格式: scp [可选參数] file_source file_target ====== 从 本地 拷贝到 远程 拷 ...