首先要采用三个协议,分别是 UINavigationControllerDelegate , UIImagePickerControllerDelegate , UIActionSheetDelegate

-(IBAction)photoClick:(id)sender {UIActionSheet *actionSheet = [[UIActionSheet alloc]initWithTitle:nil delegate:self cancelButtonTitle:@"取消" destructiveButtonTitle:nil otherButtonTitles:@"拍照",@"图库", nil];[actionSheet showInView:self.view];
}- (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex {if (buttonIndex == 0) {//拍照//资源类型为照相机UIImagePickerControllerSourceType sourceType = UIImagePickerControllerSourceTypeCamera;//判断是否有相机if ([UIImagePickerController isSourceTypeAvailable: UIImagePickerControllerSourceTypeCamera]) {UIImagePickerController *picker = [[UIImagePickerController alloc] init];picker.delegate = self;//资源类型为照相机picker.sourceType = sourceType;[self presentViewController:picker animated:YES completion:nil];} else {UIAlertView *alertView = [[UIAlertView alloc]initWithTitle:nil message:@"该设备无摄像头" delegate:self cancelButtonTitle:@"取消" otherButtonTitles: nil];[alertView show];}} else if (buttonIndex == 1) {//图库UIImagePickerController *pickerController = [[UIImagePickerController alloc] init];pickerController.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;pickerController.delegate = self;//设置选择后的图片可被编辑pickerController.allowsEditing = NO;[self presentViewController:pickerController animated:YES completion:nil];}
}-(void)imagePickerController:(UIImagePickerController*)picker didFinishPickingMediaWithInfo:(NSDictionary *)info {NSString *type = [info objectForKey:UIImagePickerControllerMediaType];//当选择的类型是图片if ([type isEqualToString:@"public.image"]) {UIImage *image = [info objectForKey:@"UIImagePickerControllerOriginalImage"];UIImageView *tempImage = [[UIImageView alloc] initWithImage:image];tempImage.frame = CGRectMake(20+picWidth+20, topImgHeight+timeImgHeight+21, UISCREEN_WIDTH-(20+picWidth+20)-20, UISCREEN_HEIGHT/2-topImgHeight-timeImgHeight-50);tempImage.userInteractionEnabled = NO;[self.view addSubview:tempImage];}[picker dismissViewControllerAnimated:YES completion:nil];
}

iOS 相机拍照与图库相关推荐

  1. iOS 相机拍照声音消失方法

    iOS 相机拍照声音消失方法 通过在拍照的时候播放一个同拍照音频文件的一个反向音频,是两个音频的声波中和,从而达到无声具体如下: static SystemSoundID soundID = 0; i ...

  2. iOS 相机拍照、相册获取照片(仿微信) 一一 拍照、图片裁剪

    最近项目做到用户自定义头像功能模块,然后仿照微信做了一个.从相册获取照片的链接在这:http://blog.csdn.net/a44496913/article/details/72979704 先来 ...

  3. Android 拍照和图库功能(适配Android 6.0和7.0系统和华为机型问题)

    众所周知,调用相机拍照和图库中获取图片的功能,基本上是每个程序App必备的. 实现适配Android每个版本,国内手机,要处理的问题却也不少.例如:Android6.0权限问题,Android7.0 ...

  4. uni-app 自定义相机拍照录像,可设置分辨率、支持横竖屏(ios、android)

    插件市场:uni-app 自定义相机拍照录像,可设置分辨率.支持横竖屏(ios.android)

  5. 相机拍照替换 IOS手机端安装使用教程

    相机拍照替换 IOS手机端安装使用教程 一.适用机型及系统 1.机型:所有iphone机型,可越狱即可 2.系统:支持13系统及以上所有可越狱系统 二.安装手机端 1.越狱 (1)Windows越狱方 ...

  6. Android开发之调用相机拍照与本地图库选择图片

    引用链接 Android开发之调用相机拍照与本地图库选择图片 Android调用相机实现拍照功能 部分截图 引言 小项目有一个访问相册的需求,在网上查找得到两位大神博客指点,但博客发布时间过旧,难免因 ...

  7. 使用AlertDialog弹窗实现相机拍照或者从图库选取图片显示

    通过图库选图片主要就是onActivityResult方法中返回的intent中获取Uri,再根据Uri和指定列名使用contentProvider去查找出此图片的路径 使用相机拍照显示之前一篇文章已 ...

  8. Unity for IOS 加载手机相册图片以及打开相机拍照获取图片

    Unity for IOS 加载手机相册图片以及打开相机拍照获取图片 最近想做一个使用unity for IOS获取手机图片的功能,所以就研究了一下 这里我们需要创建两个objective-c文件,最 ...

  9. 仿ios相机apk_icamera相机下载-icamera仿苹果软件v4.0_5577安卓网

    icamera仿苹果相机安卓下载推荐给大家!这是一款可以媲美苹果原生相机的手机软件,在拍摄手法和照片处理上还有着自己独特的见识,摄像功能也是相当强大,icamera相机还提供了专属滤镜,欢迎前来体验! ...

最新文章

  1. 开源一个上架 App Store 的相机 App
  2. 详解Scala与Java的互动
  3. boost 单io_serverce 异步多线程资源保护代码
  4. webpack打包原理(待续)
  5. 12 个有效的提高编程技能的方法
  6. 2020强网杯青少赛Pursuing_The_Wind战队WRITEUP
  7. 数据采集的目的是什么
  8. 结构体定义LNode,*LinkList和typedef struct
  9. [超详细] 2021支付宝集五福【攻略】来了-附自动化脚本
  10. 前后端请求设置签名验证,提升接口安全
  11. Atitit 常用街机系统and 模拟器总结 snk neo geo cps mame sfc smc
  12. SAP 会计科目表并存时会计科目映射
  13. 游戏制作中的大宝剑---常用的数据结构与算法
  14. 数学物理方法·复数/模/辐角引导题目
  15. 在移动硬盘上安装Ubuntu
  16. 红绿灯故障报警电路(电工实验)
  17. a标签实现文件下载(ie8可用)
  18. rails parameter permit
  19. python一元二次方程表达式_Python实现求解一元二次方程的方法示例
  20. AprilTag详解-Python实现

热门文章

  1. 纯代码告诉你:我的原弈非常(Yanj Future)是怎么下棋的
  2. Linux TF卡ext4文件系统录制视频文件用拷贝不用移动的影响
  3. [USACO13FEB]拖拉机Tractor
  4. Python邮件收发(SMTP POP3)
  5. 魔方(10)金字塔魔方、金字塔二重奏魔方
  6. qq快捷登陆 php代码,qq互联--qq快捷登陆
  7. 计算机假期计划内容,2019寒假计划,超详细学习计划表
  8. docker学习笔记(四)使用docker搭建环境
  9. 微众银行马智涛:解放数据生产力,以金融科技助力数字经济发展|数字思考者50人...
  10. QT简单添加背景图片