如何使我的ios应用程序显示在“设置”中的“位置服务”中
我写了一个CLLocationManager ios应用程序。但是,我看不到我的应用程序出现在iPhone设置中的位置服务中。我是否需要在Xcode的ios项目中的plist中设置特定值?提前谢谢 一旦调用了实际需要位置跟踪的代码(每当弹出窗口第一次显示:您允许吗…),它就会自动出现 试着打这样的电话:如何使我的ios应用程序显示在“设置”中的“位置服务”中,ios,ios5,cllocationmanager,Ios,Ios5,Cllocationmanager,我写了一个CLLocationManager ios应用程序。但是,我看不到我的应用程序出现在iPhone设置中的位置服务中。我是否需要在Xcode的ios项目中的plist中设置特定值?提前谢谢 一旦调用了实际需要位置跟踪的代码(每当弹出窗口第一次显示:您允许吗…),它就会自动出现 试着打这样的电话: [self.locationManager startUpdatingLocation]; 在iOS-8中应该可以做到这一点。需要做一些更改: locationManager = [[CLLo
[self.locationManager startUpdatingLocation];
在iOS-8中应该可以做到这一点。需要做一些更改:
locationManager = [[CLLocationManager alloc] init];
locationManager.delegate = self;
locationManager.desiredAccuracy = kCLLocationAccuracyBest;
if([locationManager respondsToSelector:@selector(requestWhenInUseAuthorization)]){
[locationManager requestWhenInUseAuthorization];
}else{
[locationManager startUpdatingLocation];
}
需要在plist中添加2个额外的键,值为空
1)不使用时的位置说明
2) NSLocationAlwaysUsageDescription
#pragma mark - CLLocationManagerDelegate
- (void)locationManager:(CLLocationManager *)manager didFailWithError:(NSError *)error
{
NSLog(@"didFailWithError: %@", error);
UIAlertView *errorAlert = [[UIAlertView alloc]
initWithTitle:@"Error" message:@"Failed to Get Your Location" delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil];
[errorAlert show];
}
- (void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation
{
NSLog(@"didUpdateToLocation: %@", newLocation);
CLLocation *currentLocation = newLocation;
if (currentLocation != nil) {
NSString *strLat = [NSString stringWithFormat:@"%.8f", currentLocation.coordinate.longitude];
NSString *strLong = [NSString stringWithFormat:@"%.8f", currentLocation.coordinate.latitude];
}
}