Iphone 在GPS中获取当前位置?
下面是我的代码,但它不工作。有人能帮我吗Iphone 在GPS中获取当前位置?,iphone,Iphone,下面是我的代码,但它不工作。有人能帮我吗 - (void)viewDidLoad { [super viewDidLoad]; CLController = [[CoreLocationController alloc] init]; CLController.delegate = self; //[CLController setDesiredAccuracy:kCLLocationAccuracyBest]; [CLController.locMgr st
- (void)viewDidLoad {
[super viewDidLoad];
CLController = [[CoreLocationController alloc] init];
CLController.delegate = self;
//[CLController setDesiredAccuracy:kCLLocationAccuracyBest];
[CLController.locMgr startUpdatingLocation];
}
- (void)locationUpdate:(CLLocation *)location {
locLabel.text = [location description];
}
- (void)locationError:(NSError *)error {
locLabel.text = [error description];
}
您没有正确执行CLocationManager委托方法
(void)locationUpdate:(CLLocation *)location {
locLabel.text = [location description];
}
应该是
- (void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation{
locLabel.text = [newLocation description];
}
在实现之前,您应该仔细阅读苹果的文档。您没有正确地使用CLocationManager委托方法
(void)locationUpdate:(CLLocation *)location {
locLabel.text = [location description];
}
应该是
- (void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation{
locLabel.text = [newLocation description];
}
在实施之前,您应该仔细阅读苹果的文档