#import <CoreLocation/CLLocationManager.h>
.h
/*
* 判断是否打开定位
*/
+ (BOOL)determineWhetherTheAPPOpensTheLocation;
.m
#pragma mark 判断是否打开定位
+(BOOL)determineWhetherTheAPPOpensTheLocation{
if ([CLLocationManager locationServicesEnabled] && ([CLLocationManager authorizationStatus] ==kCLAuthorizationStatusAuthorizedWhenInUse || [CLLocationManager authorizationStatus] ==kCLAuthorizationStatusNotDetermined || [CLLocationManager authorizationStatus] ==kCLAuthorizationStatusAuthorized)) {
return YES;
} else if ( [CLLocationManager authorizationStatus] == kCLAuthorizationStatusDenied ) {
return NO;
} else {
return NO;
}
}
if (![NSXYCToolObject determineWhetherTheAPPOpensTheLocation]) {
UIAlertView *alert = [[UIAlertView alloc]initWithTitle:@"提示"
message:@"请到设置->隐私->定位服务中开启【学易车】定位服务,以便于距离筛选能够准确获得你的位置信息"
delegate:self
cancelButtonTitle:@"取消"
otherButtonTitles:@"设置",nil];
[alert show];
}
网友评论