Ios Can';无法在我的应用程序中启用该位置
我想在我的应用程序中找到我的位置。我Ios Can';无法在我的应用程序中启用该位置,ios,Ios,我想在我的应用程序中找到我的位置。我使用CoreLocationManager获取坐标,但当我启动应用程序时,它会提醒我天气以授权位置隐私,在我单击OK按钮后,什么也没有发生 然后我打开iPhone中的设置隐私位置,我发现我的应用程序没有启用该位置。我打开它,然后重新启动应用程序,还是什么都没发生 这是我的密码: CLLocationManager *locationManager = [[CLLocationManager alloc] init]; [locationManager setD
使用CoreLocationManager
获取坐标,但当我启动应用程序时,它会提醒我天气以授权位置隐私,在我单击OK按钮后,什么也没有发生
然后我打开iPhone中的设置隐私位置,我发现我的应用程序没有启用该位置。我打开它,然后重新启动应用程序,还是什么都没发生
这是我的密码:
CLLocationManager *locationManager = [[CLLocationManager alloc] init];
[locationManager setDelegate:self];
[locationManager setDesiredAccuracy:kCLLocationAccuracyBest];
[locationManager startUpdatingLocation];
-(void)locationManager:(CLLocationManager *)manager didUpdateLocations:(NSArray *)locations
{
}
方法
-(void)locationManager:(CLLocationManager*)manager didUpdateLocations:(NSArray*)locations
在我设置断点后无法运行。将以下代码放入您的设备(而不是模拟器)中获取当前纬度和经度
很有效,谢谢!我想知道为什么它不能调用方法-(void)locationManager:(CLLocationManager*)manager didUpdateLocations:(NSArray*)locations?要调用此方法,必须在.h文件中设置
CLLocationManagerDelegate
。这个答案对你很有帮助,所以你可以向上接受它。我已经解决了这个问题,locationManager必须是访问器或成员变量。
CLLocationManager *locationManager = [[CLLocationManager alloc] init];
[locationManager setDelegate:self];
[locationManager setDesiredAccuracy:kCLLocationAccuracyBest];
[locationManager startUpdatingLocation];
CLLocation *location = [locationManager location];
CLLocationCoordinate2D coordinate = [location coordinate];
latitude = [[NSString alloc] initWithFormat:@"%f", coordinate.latitude];
longitude = [[NSString alloc] initWithFormat:@"%f", coordinate.longitude];
NSLog(@"dLatitude : %@", latitude);
NSLog(@"dLongitude : %@",longitude);