在我的viewDidLoad种方法中

locationManager = [[CLLocationManager alloc]init]; // initializing locationManager
locationManager.delegate = self; // we set the delegate of locationManager to self.
locationManager.desiredAccuracy = kCLLocationAccuracyBest;
[locationManager startUpdatingLocation];


if([[[UIDevice currentDevice] systemVersion] floatValue] >= 8.0) {
    [locationManager requestWhenInUseAuthorization];
}

调用请求,但不提示用户?为什么?

推荐答案

你可能需要更新你的plist文件.这里有一个tutorial how to do it,快速&;肮脏的:

你需要做的是在你的信息中添加以下键之一.plist文件:

NSLocationWhenInUseUsageDescription

NSLocationAlwaysUsageDescription

您还需要为相应的定位方法WhenInUseBackground请求授权.使用以下电话之一:

[self.locationManager requestWhenInUseAuthorization]
[self.locationManager requestAlwaysAuthorization]

我发现还有一个帖子很有帮助:

Location Services not working in iOS 8

这个答案详细说明了how to update your plist file:

在信息中添加以下行之一.普利斯特

<key>NSLocationWhenInUseUsageDescription</key>
<string>The spirit of stack overflow is coders helping coders</string>

<key>NSLocationAlwaysUsageDescription</key>
<string>I have learned more on stack overflow than anything else</string>

您可能需要自定义和拼写判断信息中字典条目的字符串.在shipping the code之前提交文件.

Objective-c相关问答推荐

从 float 或 double 实例化 NSDecimalNumber 的正确方法

XCTAssertEqual 错误:(3)不等于(3)

如何使用格式化占位符本地化字符串?

在 UILabel.attributedText *not* 蓝色和 *not* 下划线

右对齐的 UITextField 空格键在 iOS 7 中不前进光标

何时使用静态字符串与 #define

UILabel 的角半径属性在 iOS 7.1 中不起作用

我可以设置 `UILabel` 的 `attributedText` 属性吗

iOS 5:对 UIAppearance 感到好奇

在 32 位和 64 位架构上格式化 NS(U)Integer 时类型转换的替代方法?

如何从输入 IB 的 UILabel 文本中插入新行 \n?

IOHIDFamily 的神秘控制台错误

强制iOS应用程序崩溃的最快方法是什么?

Core Text在iOS中计算字母框架

在 DEBUG 模式下启用和禁用 NSLog

writeToFile:atomically: atomically 是什么意思?

zoom UIView 及其所有子项

点击手势识别器 - 哪个对象被点击了?

将自定义子视图(在 xib 中创建)添加到视图控制器的视图 - 我在做什么错

UICollectionView:如何检测滚动何时停止