2012-06-26 13 views
6

I in viewDidLoad Methode folgenden Code verwenden unter MethodeWie bekomme ich aktuelle Geopunkte nur einmal im iPhone?

CLLocationManager *locationManager = [[CLLocationManager alloc] init]; 
    locationManager.delegate = self; 
    locationManager.distanceFilter = kCLDistanceFilterNone; // whenever we move 
    locationManager.desiredAccuracy = kCLLocationAccuracyBestForNavigation; 
    [locationManager startUpdatingLocation]; 

Dann kontinuierlich aufgerufen wird, wenn Standort geändert.

- (void)locationManager:(CLLocationManager *)manager 
    didUpdateToLocation:(CLLocation *)newLocation 
      fromLocation:(CLLocation *)oldLocation 

Aber ich möchte aktuelle Geopunkte nur einmal. Gibt es eine Methode, die dir direkt aktuelle Geo-Punkte gibt? Ich möchte die Entfernung zwischen aktuellen Geo-Punkten und anderen Orten berechnen, wenn ich auf eine Schaltfläche klicke. Bitte hilf mir, wenn jemand weiß.

Antwort

6

In - (void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation können Sie anrufen

[manager stopUpdatingLocation]; 
Verwandte Themen