【问题标题】:Core Location iOS8 compatibility with iOS7核心位置 iOS 8 兼容 iOS7
【发布时间】:2014-12-22 07:28:27
【问题描述】:

我在我的 iOS8 兼容应用程序中编写了以下代码。该应用程序在 iOS8 上运行良好,令我惊讶的是,iOS7。我的问题是,为什么这段代码在 iOS7 上不会崩溃?

#import <CoreLocation/CoreLocation.h>
.
.
CLAuthorizationStatus authStatus = [CLLocationManager authorizationStatus];
.
// TODO some of these statuses are iOS8 only not iOS7 - need to check.
if ((authStatus == kCLAuthorizationStatusAuthorized) || (authStatus == kCLAuthorizationStatusAuthorizedAlways) ||
(authStatus == kCLAuthorizationStatusAuthorizedWhenInUse))    {
<some actual code>
}

常量 kCLAuthorizationStatusAuthorizedWhenInUse 和 kCLAuthorizationStatusAuthorizedAlways 是在 iOS8 中引入的,所以当我试图在 iOS7 模拟器中运行它时,我期待着悲剧,但它运行得很好。这是我在真正的 iOS7 设备上应该担心的问题(我现在没有设备了),还是有什么东西说这个代码在我不知道的 iOS7 上有效?

提前谢谢你。

【问题讨论】:

    标签: ios ios7 ios8 core-location


    【解决方案1】:

    在 iOS7 中,kCLAuthorizationStatusAuthorizedAlwayskCLAuthorizationStatusAuthorizedWhenInUse 枚举值通过 iOS8 SDK 映射到 kCLAuthorizationStatusAuthorized(顺便说一下,在 iOS 8 中已弃用)。这就是为什么您不会遇到任何崩溃。

    【讨论】:

      猜你喜欢
      • 2013-10-23
      • 2014-09-12
      • 2015-08-28
      • 2014-08-07
      • 1970-01-01
      • 2014-11-25
      • 2013-10-09
      • 1970-01-01
      • 2014-11-16
      相关资源
      最近更新 更多