2010-11-23 16 views

答えて

1

場所マネージャ委任

- (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); 
} 

いけない.hファイルでCLLocationManagerDelegateを含めることを忘れやCoreLocationフレームワークを追加するには、関数内で

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 

をCLLocation

CLLocationManager *locManager; 

の場所マネージャを宣言あなたのプロジェクトに

+0

ありがとうございました... – Klose

3

CLLocationManagerCLLocationManagerDelegateのドキュメントを参照してください。まだ特定の質問がある場合は、戻ってきて質問してください。