1.从系统相册中读取

/*

判断选择的读取类型是否支持

UIImagePickerControllerSourceTypePhotoLibrary,普通相册

UIImagePickerControllerSourceTypeCamera, 镜头(拍照、录视频)

UIImagePickerControllerSourceTypeSavedPhotosAlbum(自己保存的图片)

*/

if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypePhotoLibrary]) {

self.imagePC = [[UIImagePickerController alloc] init];

_imagePC.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;

//相册操作由代理来监听 取消还是选择完成

_imagePC.delegate = self;

//展示相册

[self presentViewController:_imagePC animated:YES completion:nil];

}

2.拍照录视频

if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera]) {

self.imagePC = [[UIImagePickerController alloc] init];

_imagePC.delegate = self;

_imagePC.sourceType = UIImagePickerControllerSourceTypeCamera;

//图片 public.image

//视频 public.movie

_imagePC.mediaTypes = @[@"public.movie"];

[self presentViewController:_imagePC animated:YES completion:nil];

}

3.代理

读取图片或者视频 统一回调这个代理

系统相册 一次只能选取一张

- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary<NSString *,id> *)info{

[self dismissViewControllerAnimated:YES completion:nil];

NSLog(@"%@", info);

//    UIImage *image = [info objectForKey:UIImagePickerControllerOriginalImage];

//    NSData *data = UIImagePNGRepresentation(image);

//    NSUInteger byte = data.length/8;

//    NSUInteger k = byte / 1024;

//    NSUInteger m = k / 1024;

//    NSLog(@"%ld", m);计算照片大小

}

//取消按钮被按了

- (void)imagePickerControllerDidCancel:(UIImagePickerController *)picker{

[self dismissViewControllerAnimated:YES completion:nil];

}

4.将图片保存到系统相册

UIImageWriteToSavedPhotosAlbum(image, nil, nil, nil);

系统提供的UIImagePickerController的更多相关文章

  1. 如何在Windows Server 2008 R2没有磁盘清理工具的情况下使用系统提供的磁盘清理工具

    今天,刚好碰到服务器C盘空间满的情况,首先处理了临时文件和有关的日志文件后空间还是不够用,我知道清理C盘的方法有很多,但今天只分享一下如何在Windows Server 2008 R2没有磁盘清理工具 ...

  2. iOS 动态下载系统提供的中文字体

    使用系统提供的中文字体,既可避免版权问题,又可以减小应用体积 #pragma mark - 判断字体是否已经被下载 - (BOOL)isFontDownLoaded:(NSString *)fontN ...

  3. iOS系统提供开发环境下命令行编译工具:xcodebuild

    iOS系统提供开发环境下命令行编译工具:xcodebuild[3] xcodebuild 在介绍xcodebuild之前,需要先弄清楚一些在XCode环境下的一些概念[4]: Workspace:简单 ...

  4. Swift - 访问通讯录联系人(使用系统提供的通讯录交互界面)

    1,通讯录访问介绍 通讯录(或叫地址簿,电话簿)是一个数据库,里面储存了联系人的相关信息.要实现访问通讯录有如下两种方式: (1)AddressBook.framework框架 : 没有界面,通过代码 ...

  5. Android该系统提供的服务--Vibrator(振子)

    Android该系统提供的服务--Vibrator(振子) --转载请注明出处:coder-pig Vibrator简单介绍与相关方法: watermark/2/text/aHR0cDovL2Jsb2 ...

  6. (原)SQL Server 系统提供功能的三个疑惑

    本文目录列表: 1.SQL Server系统提供的部分疑惑概述2.系统函数调用时DEFAULT代替可选参数使用不统一3.队列字段列message_enqueue_time记录的是UTC日期时间 4.@ ...

  7. 选择排序法、冒泡排序法、插入排序法、系统提供的底层sort方法排序之毫秒级比较

    我的代码: package PlaneGame;/** * 选择排序法.冒泡排序法.插入排序法.系统提供的底层sort方法排序之毫秒级比较 * @author Administrator */impo ...

  8. spring security 一个能够为基于Spring的企业应用系统提供声明式的安全访问控制解决方案的安全框架

    Spring Security是一个能够为基于Spring的企业应用系统提供声明式的安全访问控制解决方案的安全框架.它提供了一组可以在Spring应用上下文中 配置的Bean,充分利用了Spring ...

  9. UIView封装动画--iOS利用系统提供方法来做转场动画

    UIView封装动画--iOS利用系统提供方法来做转场动画 UIViewAnimationOptions option; if (isNext) { option=UIViewAnimationOpt ...

随机推荐

  1. js带箭头左右翻动控制

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...

  2. AjaxPro.2.dll使用方法简介

    1.添加对 AjaxPro.2.dll 的引用 2.在 webconfig 中 system.web 节点下 进行如下配置 <httpHandlers> <add verb=&quo ...

  3. 更换ios 开发者账号与下载别人的代码 真机调试时注意切换

    Buid Setting search sign

  4. mysql数据库在Navicat Premium连接的时候出现1862错误

    navicat连接打开时报1862的错误, 很就没有连接mysql看看了,今天连接的时候发现本机的mysql链接不上了,在cmd中执行动作的时候也会叫你去set password,做设置密码的动作时会 ...

  5. LINUX VPS 查看系统信息命令

    系统# uname -a # 查看内核/操作系统/CPU信息# head -n 1 /etc/issue # 查看操作系统版本# cat /proc/cpuinfo # 查看CPU信息# hostna ...

  6. 一些常用的js,jquerry 样例

    1 设置属性    $(document).attr("title", str) 2 删除属性在增加属性    $("#" + bottonname).remo ...

  7. [UVALive] 6492 Welcome Party(最小点覆盖)

    6492 Welcome Party For many summers, the Agile Crystal Mining company ran an internship program for ...

  8. “express不是内部或外部命令”解决办法

    由于安装的Express是最新版本4.13.1,4.x版本就需要安装express-generator.命令如下:npm install -g express-generator ps: 1.卸载: ...

  9. ng-selected 与ng-options的使用

    1:ng-selected用在<option>标签上面,ng-options用在<select>上面,用于动态创建options列表. <form class=" ...

  10. DOS的BAT技巧两则

    一,杀FF进程 二,删除FF产生的配置文件(这个大了,不小心就会爆盘) taskkill /f /t /im firefox.exe for /d %%i in (C:\Users\cheng\App ...