didUpdateLocation Method Never Called

后端 未结 6 949
南旧
南旧 2021-01-05 10:40

I am making one app on iphone sdk4.0.In that did update location method never called. I have given my code below.Please help.Thanks in advance.

-(id)init
{
          


        
6条回答
  •  滥情空心
    2021-01-05 10:55

    Furthermore in iOS8 you must have two extra things:

    • Add a key to your Info.plist and request authorization from the location manager asking it to start.

      • NSLocationWhenInUseUsageDescription

      • NSLocationAlwaysUsageDescription

    • You need to request authorization for the corresponding location method.

      • [self.locationManager requestWhenInUseAuthorization]

      • [self.locationManager requestAlwaysAuthorization]

    Code example:

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

    Source: http://nevan.net/2014/09/core-location-manager-changes-in-ios-8/

提交回复
热议问题