2013-02-24 3 views
0

je voudrais utiliser CLLocationManager pour obtenir la position actuelle sur chaque robinet sur un bouton, mais toujours obtenir les mêmes coordonnées :(toujours obtenir les coordonnées mêmes de CLLocationManager

- (void)GetCoord 
{ 
    self.currentLocation = nil; 

    self.locationManager = [[CLLocationManager alloc] init]; 
    self.locationManager.delegate = self; 
    self.locationManager.desiredAccuracy = kCLLocationAccuracyBest; 
    [self.locationManager startUpdatingLocation]; 
} 

- (void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation 
{ 
    self.currentLocation = newLocation; 

    UIAlertView *alert = [[UIAlertView alloc] 
     initWithTitle:@"Megerősítés" 
     message:[NSString stringWithFormat:@"%f ::: %f", newLocation.coordinate.latitude, newLocation.coordinate.longitude] 
     delegate:self 
     cancelButtonTitle:@"Nem" 
     otherButtonTitles:nil 
    ]; 

    [alert show]; 
    [self.locationManager stopUpdatingLocation]; 
} 
+0

Courez-vous ce par la simulateur? Peut-être que vous simulez cet emplacement.Vérifiez l'icône de l'emplacement actuel dans Xcode au-dessus du débogueur. –

Répondre

0
-(void) updateLocation 
    { 
     [locationManager startUpdatingLocation]; 
    } 



- (void)locationManager:(CLLocationManager *)manager 
     didUpdateToLocation:(CLLocation *)newLocation 
       fromLocation:(CLLocation *)oldLocation 
    { 
     userLocation.latitude = newLocation.coordinate.latitude; 
     userLocation.longitude = newLocation.coordinate.longitude; 

     [locationManager stopUpdatingLocation]; 
     //Send any notification to your controller about the update location. 
    } 
Questions connexes