2010-11-23 59 views

回答

1

聲明CLLocation

CLLocationManager *locManager; 

的位置經理在函數

self.locManager = [[CLLocationManager alloc] init]; 
locManager.delegate = self; 
locManager.desiredAccuracy = kCLLocationAccuracyBest; 
[locManager startUpdatingLocation]; // This Method will call the didUpdateToLocation Delegate 
[locManager stopUpdatingLocation]; //This Methods stops the GPS from updating 

位置管理委託

- (void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation 
{ 
//Do actions when the GPS is Updating 
} 
- (void)locationManager:(CLLocationManager *)manager didFailWithError:(NSError *)error 
{ 
    NSLog(@"Error in GPS: %@",error); 
} 

不要忘記,包括CLLocationManagerDelegate在.h文件中,並添加CoreLocation框架到您的項目

+0

感謝兄弟... – Klose 2010-11-23 13:42:31

3

查閱CLLocationManagerCLLocationManagerDelegate的文檔。如果你仍然有特定的問題,那就回來問問他們。