相关疑难解决方法(0)

iOS 8 gps未启用

我解决了一个问题,即GPS服务在iOS 7上完美运行,但在iOS 8上,我从未获得权限请求和方法:

- (void) locationManager:(CLLocationManager *)manager didUpdateLocations:(NSArray *)locations
Run Code Online (Sandbox Code Playgroud)

永远不会被召唤.

我的代码在这里:

#import "Locator.h"

@implementation Locator

- (instancetype) init {
    if (self = [super init]) {
        // Start up the location manager
        self.locationManager = [[CLLocationManager alloc] init];
        self.locationManager.delegate = self;
        self.locationManager.desiredAccuracy = kCLLocationAccuracyBest;
        self.locationManager.distanceFilter = 3;
        // New property for iOS6
        if ([self.locationManager respondsToSelector:@selector(activityType)]) {
            self.locationManager.activityType = CLActivityTypeFitness;
        }
        // New method for iOS8
        if ([self.locationManager respondsToSelector:@selector(requestAlwaysAuthorization)]) {
            [self.locationManager requestAlwaysAuthorization];
        }
    }
    return self;
}

- (void) startMonitoring:(LocationChangeCallback)callback {
    if ([CLLocationManager …
Run Code Online (Sandbox Code Playgroud)

gps objective-c cllocationmanager ios

5
推荐指数
1
解决办法
3944
查看次数

IOS 8 CLLocationManager问题(授权不起作用)

#import "MyLocationViewController.h"
#define NSLog(FORMAT, ...) printf("%s\n", [[NSString stringWithFormat:FORMAT, ##__VA_ARGS__] UTF8String]);

@interface MyLocationViewController ()

@end

@implementation MyLocationViewController

{
    CLLocationManager *locationManager;
}

- (void)requestAlwaysAuthorization
{
    [locationManager requestAlwaysAuthorization];
}

- (void)viewDidLoad
{
    [super viewDidLoad];

    // Do any additional setup after loading the view, typically from a nib.
    self.mapView.showsUserLocation = YES;
    self.mapView.delegate = self;
    locationManager = [[CLLocationManager alloc] init];

}

- (IBAction)unwindToMap:(UIStoryboardSegue *)segue
{

}

- (IBAction)getCurrentLocation:(id)sender {
    locationManager.delegate = self;
    locationManager.desiredAccuracy = kCLLocationAccuracyBest;
    [locationManager startUpdatingLocation];
}

- (void)mapView:(MKMapView *)mapView didUpdateUserLocation:(MKUserLocation *)userLocation
{
    MKCoordinateRegion …
Run Code Online (Sandbox Code Playgroud)

cllocationmanager ios

2
推荐指数
1
解决办法
7853
查看次数

标签 统计

cllocationmanager ×2

ios ×2

gps ×1

objective-c ×1