系统提供的UIImagePickerController
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的更多相关文章
- 如何在Windows Server 2008 R2没有磁盘清理工具的情况下使用系统提供的磁盘清理工具
今天,刚好碰到服务器C盘空间满的情况,首先处理了临时文件和有关的日志文件后空间还是不够用,我知道清理C盘的方法有很多,但今天只分享一下如何在Windows Server 2008 R2没有磁盘清理工具 ...
- iOS 动态下载系统提供的中文字体
使用系统提供的中文字体,既可避免版权问题,又可以减小应用体积 #pragma mark - 判断字体是否已经被下载 - (BOOL)isFontDownLoaded:(NSString *)fontN ...
- iOS系统提供开发环境下命令行编译工具:xcodebuild
iOS系统提供开发环境下命令行编译工具:xcodebuild[3] xcodebuild 在介绍xcodebuild之前,需要先弄清楚一些在XCode环境下的一些概念[4]: Workspace:简单 ...
- Swift - 访问通讯录联系人(使用系统提供的通讯录交互界面)
1,通讯录访问介绍 通讯录(或叫地址簿,电话簿)是一个数据库,里面储存了联系人的相关信息.要实现访问通讯录有如下两种方式: (1)AddressBook.framework框架 : 没有界面,通过代码 ...
- Android该系统提供的服务--Vibrator(振子)
Android该系统提供的服务--Vibrator(振子) --转载请注明出处:coder-pig Vibrator简单介绍与相关方法: watermark/2/text/aHR0cDovL2Jsb2 ...
- (原)SQL Server 系统提供功能的三个疑惑
本文目录列表: 1.SQL Server系统提供的部分疑惑概述2.系统函数调用时DEFAULT代替可选参数使用不统一3.队列字段列message_enqueue_time记录的是UTC日期时间 4.@ ...
- 选择排序法、冒泡排序法、插入排序法、系统提供的底层sort方法排序之毫秒级比较
我的代码: package PlaneGame;/** * 选择排序法.冒泡排序法.插入排序法.系统提供的底层sort方法排序之毫秒级比较 * @author Administrator */impo ...
- spring security 一个能够为基于Spring的企业应用系统提供声明式的安全访问控制解决方案的安全框架
Spring Security是一个能够为基于Spring的企业应用系统提供声明式的安全访问控制解决方案的安全框架.它提供了一组可以在Spring应用上下文中 配置的Bean,充分利用了Spring ...
- UIView封装动画--iOS利用系统提供方法来做转场动画
UIView封装动画--iOS利用系统提供方法来做转场动画 UIViewAnimationOptions option; if (isNext) { option=UIViewAnimationOpt ...
随机推荐
- Xcode7 iOS9网络配置
iOS9为了增强数据访问安全,将所有的http请求都改为了https,为了能够在iOS9中正常使用地图SDK,请在"Info.plist"中进行如下配置,否则影响SDK的使用. & ...
- MySql中PreparedStatement对象与Statement对象
PreparedStatement对象与Statement对象相比 1.代码的可读性和可维护性. 2.PreparedStatement能保证安全性(解决sql注入问题) 3.PreparedSt ...
- poj1127 Jack Straws(线段相交+并查集)
转载请注明出处: http://www.cnblogs.com/fraud/ ——by fraud Jack Straws Time Limit: 1000MS Memory L ...
- JavaScript学习笔记(三十八) 复制属性继承
复制属性继承(Inheritance by Copying Properties) 让我们看一下另一个继承模式—复制属性继承(inheritance by copying properties).在这 ...
- Android开源项目及库搜集
TimLiu-Android 自己总结的Android开源项目及库. github排名 https://github.com/trending,github搜索:https://github.com/ ...
- 在PHP中PDO解决中文乱码问题
$this->pdo = new PDO($dsn, $user, $password, array(PDO::ATTR_PERSISTENT => true)); $stmt = $th ...
- python学习第十四天 -面向对象编程基础
python也是支持面向对象编程的.这一章节主要讲一些python面向对象编程的一些基础. 什么是面向对象的编程? 1.面向对象编程是一种程序设计范式 2.把程序看做不同对象的相互调用 3.对现实世界 ...
- kakfa-性能相关
1.增大partition最大连接数 kafka的集群有多个Broker服务器组成,每个类型的消息被定义为topic,同一topic内部的消息按照一定的key和算法被分区(partition)存储在不 ...
- iOS 容易引“起循环引用”的三种场景
笔者在阅读中总结了一下,在iOS平台容易引起循环引用的四个场景: 一.parent-child相互持有.委托模式 [案例]: @interface FTAppCenterMainViewContr ...
- 学习ASP.NET的一些学习资源
ASP.NET学习相关资源 当我们在决定选择哪一个编程语言来做web开发的时候,很难选择,php.java.python这些语言是开源的,有很多的学习资源,但是当我们决定学习ASP.NET的时候,微软 ...