首页 文章

在ios 9.3.2中不调用didUpdateLocations

提问于
浏览
0

永远不会调用didUpdateLocations,而是使用被拒绝的代码 kCLErrorDenied 调用didFailWithError . 以下是我所做的事情:

#import "ViewController.h"
@import CoreLocation;

@interface ViewController () <CLLocationManagerDelegate>
@property (strong, nonatomic) CLLocationManager *locationManager;
@end

@implementation ViewController

- (void)viewDidLoad {

    [super viewDidLoad];

    // Do any additional setup after loading the view, typically from a nib.

    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];
}

- (void)didReceiveMemoryWarning {

    [super didReceiveMemoryWarning];

    // Dispose of any resources that can be recreated.

}

- (void)locationManager:(CLLocationManager *)manager didUpdateLocations:(nonnull NSArray<CLLocation *> *)locations

{

    NSLog(@"update");

}

- (void)locationManager:(CLLocationManager *)manager didFailWithError:(nonnull NSError *)error

{

    NSLog(@"error");
}

@end

NSLocationWhenInUseUsageDescriptionNSLocationAlwaysUsageDescription 插入到应用的info.plist中 . 在选择了位置更新的功能中启用后台模式 . 从非常着名的博客post获得帮助 . 我收到位置访问请求弹出窗口并允许该应用访问位置 .

但我无法获得位置更新 . 它适用于IOS 8的IPAD,但不适用于IOS版本9.3.2的ipad . 如何在IOS 9.3.2中进行位置更新?

1 回答

相关问题