Jig*_*tel 4 location dictionary ios ios7
我想检查Location Service是否on/off适用于我的应用程序,因为当我转向locaiton Service to ON但是application service is off如何?我如何通过代码检查它.
请帮忙解决我的问题.
提前致谢.
JJo*_*ton 14
对于那些试图迅速做到这一点的人.
if CLLocationManager.locationServicesEnabled() {
switch(CLLocationManager.authorizationStatus()) {
case .NotDetermined, .Restricted, .Denied:
println("No access")
case .AuthorizedAlways, .AuthorizedWhenInUse:
println("Access")
default:
println("...")
}
} else {
println("Location services are not enabled")
}
Run Code Online (Sandbox Code Playgroud)
小智 4
在locationManager:didFailWithError:,
添加这个:
-(void)locationManager:(CLLocationManager *)manager didFailWithError:(NSError *)error{
if([CLLocationManager locationServicesEnabled])
{
NSLog(@"Enabled");
if([CLLocationManager authorizationStatus]==kCLAuthorizationStatusDenied)
{
NSLog(@"Permission Denied");
}
}
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
4477 次 |
| 最近记录: |