CLLocationManagerDelegate does not call didUpdateLocations (MAP), cllocationmanager

Source: Internet
Author: User

CLLocationManagerDelegate does not call didUpdateLocations (MAP), cllocationmanager
This is because of the location permission setting problem caused by xcode upgrade.
After upgrading xcode6, open the previous xcode5 project and the program cannot be located. When the project is upgraded to xcode6, you need to write and authorize iOS8 by yourself. Otherwise, you do not have permission to locate the project.
Solution:
First, add the corresponding default field to info. plist, and set the value to YES (write the above field in the foreground positioning and write the following field in the foreground and background positioning)
NSLocationWhenInUseUsageDescription // you can obtain the GPS description on the foreground.
NSLocationAlwaysUsageDescription // allows you to obtain the GPS description in the front and back ends.
Rear chart

First run the Code:
?

123456789101112131415161718192021222324252627282930313233343536 #import "ViewController.h"#import <CoreLocation/CoreLocation.h>@interface ViewController ()<CLLocationManagerDelegate>@property (nonatomic, strong) CLLocationManager *locationManager;@end @implementation ViewController // 1. Lazy loading initialization:- (CLLocationManager *)locationManager{    if(!_locationManager){        self.locationManager = [[CLLocationManager alloc] init];        self.locationManager.delegate = self;    }    return _locationManager;} - (void)viewDidLoad {    [super viewDidLoad]; // 2. Call the request:    if ([[[UIDevice currentDevice] systemVersion] doubleValue] > 8.0)    {        // The positioning permission is valid only for ios8.        [self.locationManager requestWhenInUseAuthorization];// Foreground location                 // [LocationManager requestAlwaysAuthorization]; // locates at the front and back ends simultaneously    }    [self.locationManager startUpdatingLocation];} // 3. Proxy Method- (void)locationManager:(CLLocationManager *)manager didUpdateLocations:(NSArray *)locations{    NSLog(@"%ld",locations.count);}@end



Image: fig. PNG

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.