ios 定位是否可用的判断
2016-01-15 14:52
483 查看
- (void)locationManager: (CLLocationManager *)manager didFailWithError: (NSError *)error {
NSString *errorString;
[manager stopUpdatingLocation];
NSLog(@"Error: %@",[error localizedDescription]);
switch([error code]) {
case kCLErrorDenied:
//Access denied by user
errorString = @"用户不让访问";
//Do something...
break;
case kCLErrorLocationUnknown:
//Probably temporary...
errorString = @"定位关闭";
//Do something else...
break;
default:
errorString = @"获取不到位置信息,网络不稳定等";
break;
}
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Error" message:errorString delegate:self cancelButtonTitle:@"Ok" otherButtonTitles:nil, nil];
[alert show];
}
NSString *errorString;
[manager stopUpdatingLocation];
NSLog(@"Error: %@",[error localizedDescription]);
switch([error code]) {
case kCLErrorDenied:
//Access denied by user
errorString = @"用户不让访问";
//Do something...
break;
case kCLErrorLocationUnknown:
//Probably temporary...
errorString = @"定位关闭";
//Do something else...
break;
default:
errorString = @"获取不到位置信息,网络不稳定等";
break;
}
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Error" message:errorString delegate:self cancelButtonTitle:@"Ok" otherButtonTitles:nil, nil];
[alert show];
}
相关文章推荐
- NSURLSession断点续传
- 命令行操作ios
- 需求 - 4 - 滚动广播文字 - 2
- IOS 检查版本更新
- 干货!总结19个提升iOS开发技术的必看教程!
- IOS 用 xcode 设置 开机启动页
- IOS 用代码 设置 开机启动页
- iOS开发之添加自定义字体
- iOS8 以上版本的定位问题
- (转载)iOS 开发之EXC_BAD_ACCESS异常分析
- ios数据持久化
- iOS汉字转拼音
- 第一个iOS程序:Hello iOS
- iOS 支付宝支付
- iOS NSNotification的使用
- iOS懒加载学习笔记
- iOS开发篇(一)Cocoapods环境的配置
- iOS snow animation
- iOS开发总结
- iOS7之定制View Controller切换效果