oc获得相册照片
- (void)addImage
{
if (CGRectGetMaxX(addImageView.frame)>SCREEN_WIDTH-CGRectGetWidth(addImageView.frame)) {
[self ShowHUDTitle:@"只能添加三张图片" andDelay:];
return;
}
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 == actionSheet.cancelButtonIndex) {
}
switch (buttonIndex) {
case ://打开照相机
[self takePhoto];
break;
case ://打开相册
[self localPhoto];
break;
default:
break;
}
} -(void)takePhoto//打开相机
{
UIImagePickerControllerSourceType sourceType = UIImagePickerControllerSourceTypeCamera;
if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera]) {
UIImagePickerController *picker = [[UIImagePickerController alloc]init];
picker.delegate = self;
picker.allowsEditing = YES;
picker.sourceType = sourceType;
[self presentViewController:picker animated:YES completion:nil];
}
}
-(void)localPhoto//本地相册
{
UIImagePickerController *picker = [[UIImagePickerController alloc]init];
picker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
picker.delegate = self;
picker.allowsEditing = YES;
[self presentViewController:picker animated:YES completion:nil];
} -(void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
{
NSString *type = [info objectForKey:UIImagePickerControllerMediaType];
// 当选择的类型是图片
if ([type isEqualToString:@"public.image"]) {
// 把图片转化为NSData
UIImage *image = info[UIImagePickerControllerEditedImage];
NSData *data = UIImageJPEGRepresentation(image, 0.03); // 图片的保存路径
NSString *documentsPath = [NSHomeDirectory() stringByAppendingPathComponent:@"Documents"];
NSFileManager *manager = [NSFileManager defaultManager]; // 将刚刚转化的图片放到沙盒中 并保存为png
[manager createDirectoryAtPath:documentsPath withIntermediateDirectories:YES attributes:nil error:nil];
NSString *imageName = [NSString stringWithFormat:@"/%@.png",[NSDate date]]; [manager createFileAtPath:[documentsPath stringByAppendingString:[NSString stringWithFormat:@"%@",imageName]] contents:data attributes:nil]; //得到选择后沙盒的路径
filePath = [[NSString alloc]initWithFormat:@"%@%@",documentsPath,imageName];
NSLog(@"%@",filePath); [picker dismissViewControllerAnimated:YES completion:nil]; [imagePathList addObject:filePath]; addImageView = [[UIImageView alloc]initWithFrame:CGRectMake(CGRectGetMaxX(addImageView.frame), , SCREEN_WIDTH/, SCREEN_WIDTH/)];
addImageView.image = image;
addImageView.layer.borderWidth = ;
addImageView.layer.borderColor = [UIColor whiteColor].CGColor;
[self.view addSubview:addImageView]; CGSize size = [addressLabel.text sizeWithAttributes:@{NSFontAttributeName:[UIFont systemFontOfSize:]}];
addressLabel.frame = CGRectMake(, CGRectGetMaxY(addImageView.frame), size.width+, ); inputView.frame = CGRectMake(, CGRectGetMaxY(addressLabel.frame), SCREEN_WIDTH, SCREEN_HEIGHT-CGRectGetMaxY(addressLabel.frame)); }
}
- (void)imagePickerControllerDidCancel:(UIImagePickerController *)picker
{
[picker dismissViewControllerAnimated:YES completion:nil];
}
oc获得相册照片的更多相关文章
- Android7.0调用系统相机拍照、读取系统相册照片+CropImageView剪裁照片
Android手机拍照.剪裁,并非那么简单 简书地址:[我的简书–T9的第三个三角] 前言 项目中,基本都有用户自定义头像或自定义背景的功能,实现方法一般都是调用系统相机–拍照,或者系统相册–选择照片 ...
- QQ空间相册照片批量导出
QQ空间相册照片批量导出 先自己创建一个私人的单独的群,然后创建相册,上传照片来源从空间选图复制 复制完成后打开相册开始骚操作(两种方式) OK
- Android开发之获取相册照片和获取拍照照片
在Android的开发过程中,我们可能会读取手机里面的照片或者通过相机拍摄获取照片,这是两种常用的获取图片的方式,在做项目过程中也会经常遇到,下面来介绍一下这两种获取方式.. 1.从本地相册获取照片: ...
- iOS UIWebView 中 js调用OC 打开相册 获取图片, OC调用js 将图片加载到html上
线上html <!DOCTYPE html> <html> <head> <title>HTML中用JS调用OC方法</title> < ...
- Androd选取相册照片和拍照处理-android学习之旅(62)
实现如下图所示效果 核心代码 -构建打开相册和拍照的Intent 拍照 File outputImage = new File(Environment.getExternalStorageDirect ...
- Android开发之获取相册照片和获取拍照照片二
转至 http://blog.csdn.net/beyond0525/article/details/8940840 上一篇文章中讲解了照相机获取照片的时候遇到了可能取得的uri为null的状态,并给 ...
- 怎么SDCard上的获取相册照片
private String getRealPathFromURI(Uri contentUri) { Cursor cursor = null; String result = contentUri ...
- cordova获取相册照片插件的使用方法:cordova-plugin-image-picker
1. 添加插件:cordova plugin add cordova-plugin-image-picker 2.调用方法: 3.参考 : http://www.cnblogs.com/lyxy/p/ ...
- 【纯代码】Swift相册照片选择-支持单选或多选
// // NAPublishAlbumTableViewController.swift //// // Created by on 2019/3/23. // Copyright © 2019年 ...
随机推荐
- 被拒原因——You have selected the Kids Category for your app, but it does not include the required privacy policy. Please update your app metadata to include a privacy policy URL and ensure that the URL yo
对于一些孩子类的应用,必须加上隐私政策网址(URL),直接截个图吧! 就是你上架的时候,填写应用信息,里面有一个隐私政策网址(URL),望后者不掉坑里了!!!
- 如何给wordpress外部链接自动添加nofollow
wordpress多作者博客可以丰富网站的内容,但同时也会产生一些无关的链接,例如有些投机的人会考虑在文章中随意添加外部链接,如果你不想给这些外部链接传递权重,你需要给这些外部链接加上 rel=&qu ...
- SqlServer中字符串和日期类型的转换
SQL Server Date 函数 定义和用法 CONVERT() 函数是把日期转换为新数据类型的通用函数. CONVERT() 函数可以用不同的格式显示日期/时间数据. 语法 CONVERT(da ...
- 【C语言入门教程】7.4 共用体
7.4 共用体 共用体又称为联合体,是由不同的数据类型组成的一个整体.与结构体不同的是,共用体每次只能使用其中一个成员.结构体的总长度是结构体所有成员长度之和,共用体的总长度是其中最长一个数据类型的长 ...
- vue.js 简单入门
转载自:http://blog.csdn.net/violetjack0808/article/details/51451672 <!DOCTYPE html> <html lang ...
- 小心一些,断言可能让你的造成循环引用NSAssert
block和self的相互引用造成的循环引用,想必大家都是明白的.上下面的代码(截取部分) __weak typeof(self) weakSelf = self; self.jsBridgeFunc ...
- Oracle 10G select工作原理
数据库查询语句内部执行过程 select * from table 步骤 分析阶段(parse) 1.共享池库高速缓存有没有该语句.如果有直接返回结果. 2.语法分析sql语句是否正确进行下一步分析 ...
- Java BigDecimal详解
借用<Effactive Java>这本书中的话,float和double类型的主要设计目标是为了科学计算和工程计算.他们执行二进制浮点运算,这是为了在广域数值范围上提供 较为精确的快速近 ...
- Kali Linux渗透基础知识整理(二)漏洞扫描
Kali Linux渗透基础知识整理系列文章回顾 漏洞扫描 网络流量 Nmap Hping3 Nessus whatweb DirBuster joomscan WPScan 网络流量 网络流量就是网 ...
- Maven的作用总结
前言: maven项目也是一个项目,类似于javaProject,javaWebProject,就是多了些功能! 1 . 帮你下载jar包 maven项目会有一个 pom.xml文件, 在这个文件里面 ...