iPhone sdk位置变更通知

时间:2010-11-23 12:34:34

标签: iphone

我计划在iPhone上进行GPS定位。你能告诉我有关GPS的信息(代表,方法等)。

2 个答案:

答案 0 :(得分:3)

查找CLLocationManagerCLLocationManagerDelegate的文档。如果您还有具体问题,请回来问问他们。

答案 1 :(得分: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);  
}

不要忘记在.h文件中包含CLLocationManagerDelegate并将CoreLocation Framework添加到项目中