iOS 拍照与相片选择,在模拟器上拍照时做一个友好提示
来源:互联网 发布:p2p远程监控软件 编辑:程序博客网 时间:2024/05/22 15:07
{
UIActionSheet *sheet = [[UIActionSheet alloc]init];
[sheet addButtonWithTitle:@"拍照"];
[sheet addButtonWithTitle:@"从相册选择"];
[sheet addButtonWithTitle:@"取消"];
[sheet setCancelButtonIndex:2];
[sheet setDelegate:self];
sheet.tag = 255;
[sheet showInView:self.view];
}
#pragma mark - actionsheet delegate
- (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex{
if (actionSheet.tag == 101) {
UIImagePickerController *pickController = [[UIImagePickerController alloc] init];
pickController.delegate = self;
[pickController.navigationBar setTitleTextAttributes:@{NSForegroundColorAttributeName:[UIColor whiteColor]}];
if (buttonIndex == 0) {
AVAuthorizationStatus authStatus = [AVCaptureDevice authorizationStatusForMediaType:AVMediaTypeVideo];
if ((authStatus == AVAuthorizationStatusRestricted || authStatus == AVAuthorizationStatusDenied) && iOS7Later) {
// 无相机权限 做一个友好的提示
UIAlertView * alert = [[UIAlertView alloc]initWithTitle:@"无法使用相机" message:@"请在iPhone的""设置-隐私-相机""中允许访问相机" delegate:self cancelButtonTitle:@"取消" otherButtonTitles:@"设置", nil];
[alert show];
} else { // 调用相机
// UIImagePickerControllerSourceType sourceType = UIImagePickerControllerSourceTypeCamera;
if ([UIImagePickerController isSourceTypeAvailable: UIImagePickerControllerSourceTypeCamera]) {
pickController.sourceType = UIImagePickerControllerSourceTypeCamera;
[self presentViewController:pickController animated:YES completion:nil];
} else {
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:nil message:@"模拟器里不支持拍照,请在真机上测试!" delegate:nil cancelButtonTitle:nil otherButtonTitles:nil];
[NSTimer scheduledTimerWithTimeInterval:3.0f target:self selector:@selector(timerFireMethod:) userInfo:alert repeats:YES];
[alert show];
}
}
}
if (buttonIndex == 1) {
pickController.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
[self presentViewController:pickController animated:YES completion:nil];
}
}
}
-(void)timerFireMethod:(NSTimer*)theTimer//弹出框
{
UIAlertView *promptAlert = (UIAlertView*)[theTimer userInfo];
[promptAlert dismissWithClickedButtonIndex:0 animated:NO];
promptAlert =NULL;
}
原文版权归作者所有,转载请注明来源
- iOS 拍照与相片选择,在模拟器上拍照时做一个友好提示
- android选择相片和拍照保存
- ios 拍照与摄像
- Android7.0上拍照与选择照片Crash问题
- iOS-UIImagePickerController拍照与摄像
- iOS 拍照
- 通过phonegap拍照,然后把相片上传到服务器上的某个文件夹上。
- 点击按钮连接到图库和拍照选择相片到EditText
- android 相机拍照后选择照片编辑,相片编辑界面直线形状会显示锯齿状
- Android 相片管理专题之拍照功能
- 五.拍照存储相片过程分析
- 调用手机相机拍照并裁剪相片
- 解决Android调用系统相机拍照后相片无法在相册中显示问题
- 拍照
- 拍照
- 拍照
- 拍照
- 拍照
- Presents
- Access键盘快捷键大全(十一)
- 面试题六--XML部分
- MongoEngine对Django支持的官方文档翻译
- OneCoin(维卡币)卖币指南(Zz-Team)
- iOS 拍照与相片选择,在模拟器上拍照时做一个友好提示
- PostgreSQL学习篇9.1 布尔类型
- apache的三种工作模式
- cpp 8.3
- Access键盘快捷键大全(十二)
- UC/OS-II 任务的状态
- GCD之dispatch queue深入浅出
- Keytool工具的常见用法
- 视图滚动的七种方式--Android Scroll