Frage

I am updating my device location using CoreLocation

-(void)viewDidLoad
{
[super viewDidLoad];
self.locationManager = [[CLLocationManager alloc] init];
self.locationManager.desiredAccuracy = kCLLocationAccuracyBest;
self.locationManager.delegate = self;
[self.locationManager startUpdatingLocation];
 }


-(void)locationManager:(CLLocationManager *)manager didUpdateLocations:(NSArray *)locations {

   CLLocation *loc = locations.lastObject;
   double speed = loc.speed;
   NSLog(@"speed-----%f ", speed);
    }

When I test it with simulator it updates every seconds and I am getting the speed (By giving simulator location Freeway Drive) But when I test with real device it updates location in an interval of 10-15 seconds. Why this happens, Please help me ?

War es hilfreich?

Lösung

You should try to set the "pausesLocationUpdatesAutomatically" property to NO. So, self.locationManager.pausesLocationUpdatesAutomatically = NO;

Default value is YES and in that case LocationManager stops updating locations when "it thinks" location is unlikely to change.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top