2010-10-25 4 views
2

Ci-dessous est mon code, mais il ne fonctionne pas. Quelqu'un peut-il m'aider???l'obtention de l'emplacement actuel dans le GPS?

- (void)viewDidLoad { 
    [super viewDidLoad]; 

    CLController = [[CoreLocationController alloc] init]; 
    CLController.delegate = self; 
    //[CLController setDesiredAccuracy:kCLLocationAccuracyBest]; 
    [CLController.locMgr startUpdatingLocation]; 
} 

- (void)locationUpdate:(CLLocation *)location { 
    locLabel.text = [location description]; 
} 

- (void)locationError:(NSError *)error { 
    locLabel.text = [error description]; 
} 

Répondre

0

vous ne faites pas les méthodes de délégué CLocationManager correctement

(void)locationUpdate:(CLLocation *)location { 
    locLabel.text = [location description]; 
} 

devrait être

- (void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation  *)newLocation fromLocation:(CLLocation *)oldLocation{ 
locLabel.text = [newLocation description]; 
} 

Vous devriez lire la documentation d'Apple http://developer.apple.com/library/ios/#documentation/CoreLocation/Reference/CLLocationManagerDelegate_Protocol/CLLocationManagerDelegate/CLLocationManagerDelegate.html%23//apple_ref/doc/uid/TP40007124 sur ce bien avant sa mise en œuvre.