【发布时间】:2010-11-23 12:34:33
【问题描述】:
我打算在 iPhone 上进行 GPS 定位。能否告诉我有关 GPS 的信息(代表、方法等)。
【问题讨论】:
标签: iphone
我打算在 iPhone 上进行 GPS 定位。能否告诉我有关 GPS 的信息(代表、方法等)。
【问题讨论】:
标签: iphone
查找CLLocationManager 和CLLocationManagerDelegate 的文档。如果您仍有具体问题,请回来询问。
【讨论】:
声明一个 CLLocation 的 Location Manager
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 框架添加到您的项目中
【讨论】: