iphone - 检测 iPhone 设备的 Core Location 功能

标签 iphone objective-c cocoa core-location

我正在编写一个核心位置应用程序,利用 startMonitoringSignificantLocationChanges 方法在适当的时候生成更新,但这不适用于 iPhone 3g 等旧设备。

我希望核心位置功能在设备打开时仍然可以工作,所以我想我可以使用选择器测试来查看设备是否支持该方法,以及它是否不只使用标准核心位置更新方法。尽管此选择器在我的 iphone 3g 上不起作用,但它仍然使用 startMonitoringSignificantLocationChanges,即使它在手机上不起作用。

有什么想法吗?我宁愿不使用设备标识符测试,因为这样就必须针对 future 的每个手机版本进行更新。

   @interface RootViewController : UITableViewController  <CLLocationManagerDelegate>  {
    CLLocationManager *locationManager;     
}
@property (nonatomic, retain) CLLocationManager *locationManager;

@implementation RootViewController
@synthesize locationManager;
    if([locationManager respondsToSelector:@selector(startMonitoringSignificantLocationChanges)]) {
            [locationManager startMonitoringSignificantLocationChanges];
            NSLog(@"Using bg updates");
        }
        else {
            [locationManager startUpdatingLocation];
            NSLog(@"Using reg updates");
        }

最佳答案

if ([CLLocationManager significantLocationChangeMonitoringAvailable]) {
…
}

关于iphone - 检测 iPhone 设备的 Core Location 功能,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3929912/

相关文章:

iphone - 如何使用 FacebookSDK v3.21 获取 facebook 登录用户的好友列表

iphone - init ViewController 根据传入的参数加载不同的 XIB

iphone - 如何在 IOS 设备上运行我的项目?

objective-c - 如何禁用 UITableView 垂直向上滚动?

cocoa - 如何将 NSData 转换回原始文件?

swift - 在 Swift 中初始化 NSWindowController 对象的正确方法是什么?

iphone - 在 iOS 5.1 中创建具有不同样式文本的 UILabel,而不使用 Storyboard

iphone - 如何确定 UICollectionView flowLayout 中单元格之间的间距

ios - 签名无效 - 代码对象根本没有签名

cocoa - iOS 一年中的某一天