我计划在iPhone上进行GPS定位。你能告诉我有关GPS的信息(代表,方法等)。
答案 0 :(得分:3)
查找CLLocationManager
和CLLocationManagerDelegate
的文档。如果您还有具体问题,请回来问问他们。
答案 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添加到项目中