首先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. 需要一个分页,花了一个钟写了一个,刚学js,不是很完美

    <script src="js/jquery.min.js" ></script> <script type="text/javascrip ...

  2. DHCP服务自动分配IP地址原理

    转载自:http://blog.csdn.net/lycb_gz/article/details/8499559 DHCP在提供服务时,DHCP客户端是以UDP 68号端口进行数据传输的,而DHCP服 ...

  3. PowerShell 批量增加ACL

    $serviceName="云服务名称"$vmName="虚拟机名称"$endPoint="终结点名称"$acl=New-AzureAclC ...

  4. Linux下root密码忘记的解决办法

    {启动方式} ========================================================================== 一. lilo 1. 在出现 lil ...

  5. hdu 1093 A+B for Input-Output Practice (V)

    A+B for Input-Output Practice (V) Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/3276 ...

  6. jQuery 判断div是否shown

    // Checks for display:[none|block], ignores visible:[true|false] $(element).is(":visible") ...

  7. 用js实现选项卡切换效果

    这是要实现的效果图: 一.HTML页面布局 <!-- HTML页面布局 --><ul class="tab_menu"> <li class=&quo ...

  8. scala学习笔记:各种奇怪的写法

    Unit函数的定义: def foo()={println("hi")} 等号可以省略: def foo(){println("hi")} update方法: ...

  9. ASP怎样获得代码中第一张图片地址

    '把pattern 又修改了下 'code要检测的代码 'http://www.knowsky.com/asp.asp 'leixing html 或者ubb 'nopic 代码没有图片时默认值 fu ...

  10. ACM——第几天

    第几天 时间限制(普通/Java) : 1000 MS/ 3000 MS          运行内存限制 : 65536 KByte总提交 : 1830            测试通过 : 525 描 ...