JFELocationManager 0.1.2

JFELocationManager 0.1.2

测试已测试
语言语言 Obj-CObjective C
许可证 MIT
发布上次发布2015年5月

Jerome Freyre 维护。



  • 作者:
  • Jérome Freyre

这是一个 CoreLocation 封装 (单例) 以允许在整个应用程序中进行内部使用。

在您的 AppDelegate 文件或其他位置调用 [JFELocationManager sharedInstance]; 以初始化单例并自动开始更新位置和航向

关于 iOS 8 呢?

JFELocationManager 现在已准备好支持 iOS 8。要启用此库,您必须在您的 Info.plist 文件中添加一个新的条目。

NSLocationAlwaysUsageDescription = "The message to be shown";

用法

设置控制器为

@interface JFEViewController : UIViewController<JFELocationManagerDelegate>

然后您可以根据需要实现以下(或其中之一)委托方法

-(void) didUpdateHeading:(CLHeading *)newHeading;
-(void) didUpdateLocation:(CLLocation*) location;
-(void) didChangeAuthorizationStatus:(CLAuthorizationStatus)status;

要允许后台更新,您必须在您的 appdelegate 文件中定义这些方法

- (void)applicationDidEnterBackground:(UIApplication *)application
{
    // ... Do something else ...
    // Force to disable the location update only if there is no "important delegate"
    if ([JFELocationManager sharedInstance].importantDelegate == nil) {
        NSLog(@"AppDelegate -> I disable updating location");
        [[JFELocationManager sharedInstance] stop];
    }

}

- (void)applicationDidBecomeActive:(UIApplication *)application
{
    // ... Do something else ...
    if ([JFELocationManager sharedInstance].importantDelegate == nil) {
        [[JFELocationManager sharedInstance] start];
        NSLog(@"AppDelegate -> I enable updating location");
    }
}

要求

iOS 6.0 及以上。

用法

JFELocationManager.h/m 添加到您的项目中,或使用 CocoaPods 添加 pod 'JFELocationManager'

作者

Jerome Freyre, [email protected]

许可证

JFELocationManager 在 MIT 许可证下可用。有关更多信息,请参阅 LICENSE 文件。