如何使我的ios应用程序出现在设置中的位置服务

我写了一个CLLocationManager ios应用程序。 但是,我看不到我的应用程序出现在我的iPhone设置中的定位服务中。 我需要在Xcode的ios项目中设置plist的特定值吗? 提前致谢!

一旦实际需要位置跟踪的代码被调用,它就会自动出现(只要popup窗口第一次显示:你允许…)

尝试调用这样的东西:

[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)NSLocationWhenInUseUsageDescription 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]; } }