服装网站建设配色/抖音排名优化
升级了ios8后发现,程序在ios8系统的设置里面不能打开定位开关了,一旦打开,就会被关闭。
原因在于ios8需要做特殊处理。
需要做如下的处理:
//开启后台定位
-(void)startSignificantChangeUpdates
{NSLog(@"=======startSignificantChangeUpdates=========");// if location services are restricted do nothingif ([CLLocationManager authorizationStatus] == kCLAuthorizationStatusDenied ||[CLLocationManager authorizationStatus] == kCLAuthorizationStatusRestricted ){//弹出 请打开定位的提示UIAlertView *alert = [[UIAlertView alloc] initWithTitle:NSLocalizedString(@"text_location_service_off_warning_title", @"") message:NSLocalizedString(@"text_location_service_off_warning_content", @"") delegate:nil cancelButtonTitle:NSLocalizedString(@"text_no", @"") otherButtonTitles:NSLocalizedString(@"text_ok", @""), nil];[alert show];return ;}if (SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(@"8.0")){[locationManager requestAlwaysAuthorization];}[locationManager startMonitoringSignificantLocationChanges];[locationManager startUpdatingLocation];isUpdatingLocation = YES;
}
然后还需要在plist文件中,添加两个字段:
NSLocationAlwaysUsageDescription 跟 NSLocationWhenInUseDescription
类型为string ,留空即可。
这样就可以开启 “始终” 定位开关。