简体   繁体   English

iPhone SDK位置更改通知

[英]iPhone sdk location change notification

I am planning to do GPS location on iPhone. 我打算在iPhone上进行GPS定位。 Can you tell me the information regarding GPS (delegates,methods etc). 您能告诉我有关GPS的信息(代理,方法等)。

Look up the documentation for CLLocationManager and CLLocationManagerDelegate . 查找有关CLLocationManagerCLLocationManagerDelegate的文档。 If you still have specific questions then, come back and ask them. 如果您还有其他问题,请回来询问。

Declare a Location Manager of CLLocation 声明CLLocation的位置经理

CLLocationManager *locManager;

In your Function 在你的职能

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

Location Manager Delegate 位置经理代表

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

Dont forget to include CLLocationManagerDelegate in .h file and Add CoreLocation Framework to your project 不要忘记在.h文件中包括CLLocationManagerDelegate并将CoreLocation Framework添加到您的项目中

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM