[英]GPS location is on/off in iphone for my app
i am check GPS
location is on/off
to use this code 我正在检查
GPS
位置是on/off
使用此代码
BOOL servicesEnabled = [CLLocationManager locationServicesEnabled];
it work correctly when on/off LocationServices in iphone,but i am set off LocationServices for my app it return only servicesEnabled
to YES
,that time [CLLocationManager locationServicesEnabled]
how to check locationServicesEnabled
in my app Ex: i am disable my app location services like as instagram, how to solve this problem to check LocationServices
in particular app in iphone or ipad? 它在iphone中打开/关闭LocationServices时工作正常,但我为我的应用程序设置了LocationServices它只返回
servicesEnabled
为YES
,那时候[CLLocationManager locationServicesEnabled]
如何在我的应用程序中检查locationServicesEnabled
Ex:我禁用我的应用程序位置服务像作为Instagram,如何解决这个问题来检查在iPhone或iPad的特定应用程序中的LocationServices
?
Use your CLLocationManagerDelegate's locationManager: didFailWithError:
method and check for a kCLErrorDenied
error to see if the user denied location services. 使用您的
CLLocationManagerDelegate's locationManager: didFailWithError:
方法并检查kCLErrorDenied
错误以查看用户是否拒绝了位置服务。
- (void)viewDidLoad
{
locationManager = [[CLLocationManager alloc] init];
locationManager.delegate = self;
locationManager.desiredAccuracy = kCLLocationAccuracyKilometer;
// Set a movement threshold for new events.
locationManager.distanceFilter = 500;
[locationManager startUpdatingLocation];
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
}
- (void)locationManager:(CLLocationManager *)manager
didUpdateLocations:(NSArray *)locations {
// If it's a relatively recent event, turn off updates to save power
}
- (void)locationManager:(CLLocationManager *)manager didFailWithError:(NSError *)error
{
NSLog(@"%@",error);
}
if location service disable for your app then its give you error 如果位置服务禁用您的应用程序,那么它会给您错误
Error Domain=kCLErrorDomain Code=1 "The operation couldn’t be completed. (kCLErrorDomain error 1.)"
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.