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. Objective-C Delegate

    ios设计模式中的委托 Delegate 官方文档解释如下: Delegation is a simple and powerful pattern in which one object in a ...

  2. linux内核学习之三:linux中的"32位"与"64位"

    在通用PC领域,不论是windows还是linux界,我们都会经常听到"32位"与"64位"的说法,类似的还有"x86"与"x86 ...

  3. Kafka笔记--使用ubuntu为bocker(服务器)windows做producer和comsumer(客户端)

    原文连接:http://www.cnblogs.com/davidwang456/p/4201875.html 程序仍然使用之前的一篇博文中的例子 :http://www.cnblogs.com/gn ...

  4. SolrCloud初识

    文章摘自:http://www.bubuko.com/infodetail-923588.html 一.概述 Lucene是一个Java语言编写的利用倒排原理实现的文本检索类库: Solr是以Luce ...

  5. Qt也有垃圾回收(通过QScopedPointer实现),下决心在项目里使用QScopedPointer,省了太多事情了,而且更安全!!

    也谈Qt的垃圾回收 前几天在做代码审核的时候,Kai Uwe Broulik建议使用QScopedPointer来替代手工内存管理,使用后发觉确实节约了不少代码量,我的CHERRY可以延长寿命了!但是 ...

  6. BZOJ1628: [Usaco2007 Demo]City skyline

    1628: [Usaco2007 Demo]City skyline Time Limit: 5 Sec  Memory Limit: 64 MBSubmit: 256  Solved: 210[Su ...

  7. jQuery旋转插件jqueryrotate 图片旋转

    "jquery.rotate.min.js"是jQuery旋转rotate插件,支持Internet Explorer 6.0+ .Firefox 2.0 .Safari 3 .O ...

  8. c语言通过时间种子产生随机数并选出最大值以及下标

    1 #include <stdio.h> #include <stdlib.h> #include <time.h> //2016 10 10 void main( ...

  9. Bootstrap--本地安装使用

    1.到官网下载:http://v2.bootcss.com 2.下载后是一个压缩文件,把它放在相应的工作目录下,然后解压. 3.新建一个测试文件,然后导入两个文件.

  10. JQuery的父、子、兄弟节点查找,节点的子节点循环

    Query.parent(expr)           //找父元素 jQuery.parents(expr)          //找到所有祖先元素,不限于父元素 jQuery.children( ...