首先plist定义两个string:
 NSLocationWhenInUseUsageDescription
NSLocationAlwaysUsageDescription
然后调用
[self.locationManager requestWhenInUseAuthorization]
或者
[self.locationManager requestAlwaysAuthorization]
例如
#import "ViewController.h"
@import CoreLocation;
 
@interface ViewController ()
@property (strong, nonatomic) CLLocationManager *locationManager;
@end
 
@implementation ViewController
 
- (void)viewDidLoad
{
    [super viewDidLoad];
 
    // ** Don't forget to add NSLocationWhenInUseUsageDescription in MyApp-Info.plist and give it a string
 
    self.locationManager = [[CLLocationManager alloc] init];
    self.locationManager.delegate = self;
    // Check for iOS 8. Without this guard the code will crash with "unknown selector" on iOS 7.
    if ([self.locationManager respondsToSelector:@selector(requestWhenInUseAuthorization)]) {
        [self.locationManager requestWhenInUseAuthorization];
    }
    [self.locationManager startUpdatingLocation];
}
 
// Location Manager Delegate Methods    
- (void)locationManager:(CLLocationManager *)manager didUpdateLocations:(NSArray *)locations
{
    NSLog(@"%@", [locations lastObject]);
}
 
@end

iOS 8 定位失败问题的更多相关文章

  1. iOS设备定位

    一.iOS谈到定位 1.SignInSignOutViewController.h @interface SignInSignOutViewController : UIViewController& ...

  2. iOS地图 -- 定位初使用

    iOS的定位服务用到的框架是#import <CoreLocation/CoreLocation.h> 定位中用到的类是CLLocationManager 一.iOS8.0之前的定位 向用 ...

  3. iOS后台定位实现

    iOS后台定位实现 (2013-01-24 16:43:12)     工作中碰到一个定位的应用场景:app需要在后台运行,实时上传用户地理位置.   苹果对iOS的规范性在提升了app的品质的同时也 ...

  4. android 高德地图出现【定位失败key鉴权失败】

    如题:android 高德地图出现[定位失败key鉴权失败] 原因:使用的是debug模式下的SHA1,发布的版本正确获取SHA1的方式见: 方法二使用 keytool(jdk自带工具),按照如下步骤 ...

  5. iOS 后台定位被拒注意事项

    iOS 后台定位被拒的原因很简单就是没有达到苹果对后台定位的要求. 本地要求: 1.在plist文件中添加字段 "Privacy - Location Always Usage Descri ...

  6. 由于IPv6导致的iOS应用发布失败,是否该怪Azure?

    IPv6已经被越来越广泛的支持了,尤其是苹果强制要求iOS (确切的说是iOS 9以及后续版本)应用必须支持IPv6之后(官方宣布),更将进一步推动IPv6的使用. 不过苹果应用作为客户端强制要求IP ...

  7. ionic在iOS中打包失败

    在ios中打包失败,遇上这样的错误 解决办法,查看index.html的权限是否是只读状态,如果是,改成可读可写,再次打包重试,成功!

  8. iOS CLLocationManager定位

    本文转载至 http://www.tuicool.com/articles/7JBRZn 在iOS8以前的版本中,我们使用CLLocationManager定位是没有问题的,最近在iOS8系统中却无法 ...

  9. iOS8 定位失败问题

    iOS7升级到iOS8后,百度地图 iOS SDK 中的定位功能不可用,给广大开发者带来了不便,在此向大家分享一个方法来解决次问题.(官方的适配工作还在进行中,不久将会和广大开发者见面) 1.在inf ...

随机推荐

  1. 如何使用ZBLibrary-Android快速开发框架

    1.下载: 点击右边这个地址 https://github.com/TommyLemon/Android-ZBLibrary 点击DownloadZip即可. 2.解压 3.用ADT-Bundle(集 ...

  2. Intent实现页面跳转

    Intent实现页面跳转: 1. startActivity(intent) 2. startActivityForResult(intent,requestCode); onActivityResu ...

  3. Forwarding a Range of Ports in VirtualBox

    STAN SCHWERTLY MAY 9, 2012 ARTICLES 3 COMMENTS Doesn't allow forwarding a range of ports through the ...

  4. Apache配置虚拟主机后,不能访问localhost的问题

    今天想试用一下php7,但是发现php7只支持Apache2.4版本,而我电脑上的Apache是2.2版本,为了想尝鲜,就必须去下载新的Apache2.4 php7和apache2.4安装整合以后,l ...

  5. httperf ---linux web站点压力测试

    一.工具下载&&安装 软件获取 ftp://ftp.hpl.hp.com/pub/httperf/ 这里使用的是如下的版本 ftp://ftp.hpl.hp.com/pub/httpe ...

  6. android之TCP客户端框架

    一.程序框架 1.1 创建方法 onCreate 1.1.1 创建连接按键线程,并使能线程(触发原因:可按键.其他操作,并进行状态判断): Connect_Thread connect_Thread ...

  7. webbreswer 转成ie11

    http://zhidao.baidu.com/link?url=pvYg-Z5fjOaFHrpdxFSjrDqkaUpvc-tY5VwtLjd7bfmdG4T80i0Rqkkv1zcApZiIq6w ...

  8. .NET技能分析

    知乎话题:如何面试.NET/ASP.NET工程师? No.1初级:1.对 C#(推荐) 或 VB 语言直至与 .NET 4 (目前为止)相匹配的版本,绝大多数特性熟悉并使用过2.通晓 HTTP 协议的 ...

  9. Echarts基于动态数据初步使用 及问题 代码记录.

    ECHARTS 插件 基本的动态数据展示(横向图) 下载 echarts.commn.min.js文件 在页面中进行引用, 并为Echarts图形准备一个div盒子 <!-- 引入插件 --&g ...

  10. C# 接口的隐式与显示实现【转】

    以前在用到接口时,从来没注意到接口分为隐式实现与显示实现.昨天在浏览博客时看到相关内容,现在根据自己的理解记录一下,方便日后碰到的时候温习温习.通俗的来讲,“显示接口实现”就是使用接口名称作为方法名的 ...