iOS-保存图片到相册
//保存
UIButton *saveBtn = [[UIButton alloc] init];
// saveBtn.frame = CGRectMake((screenWidth-270)/4+1, 550/9*screenScale + 272/9*screenScale + 128/9*screenScale + 172/9*screenScale + 55,133, 42);
saveBtn.frame = CGRectMake((screenWidth-270)/4+1,1766/3,133, 42);
[saveBtn setTitle:@"保存" forState:UIControlStateNormal];
[saveBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
[saveBtn setBackgroundColor:[UIColor colorWithRed:58/256.0 green:150/256.0 blue:253/256.0 alpha:1.0f]];
[saveBtn addTarget:self action:@selector(save) forControlEvents:UIControlEventTouchUpInside];
saveBtn.titleLabel.font = [UIFont systemFontOfSize:17];
[self.view addSubview:saveBtn];
-(void)save
{
NSLog(@"---save");
// //如果你的系统大于等于7.0 >
// if (floor(NSFoundationVersionNumber) > NSFoundationVersionNumber_iOS_6_1) {
//
// UIAlertView *alertView = [[UIAlertView alloc]initWithTitle:@"" message:@"保存二维码到相册" delegate:self cancelButtonTitle:@"确定" otherButtonTitles:nil];
// alertView.tag = 1;
// [alertView show];
//
// }else{
//
// //>=iOS8以上才有alertController这个方法
// UIAlertController *alertController = [UIAlertController alertControllerWithTitle:@"" message:@"保存二维码到相册" preferredStyle:UIAlertControllerStyleAlert];
// UIAlertAction *okAction = [UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {
// UIImageWriteToSavedPhotosAlbum(_codeView.image, self, @selector(image:didFinishSavingWithError:contextInfo:), nil);
// }];
//
// UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {
//
// }];
//
// [alertController addAction:cancelAction];
// [alertController addAction: okAction];
// [self presentViewController:alertController animated:YES completion:nil];
//
//}
UIAlertView *alertView = [[UIAlertView alloc]initWithTitle:@"" message:@"保存二维码到相册" delegate:self cancelButtonTitle:@"确定" otherButtonTitles:nil];
alertView.tag = 1;
[alertView show];
}
- (void)image:(UIImage *)image didFinishSavingWithError:(NSError *)error contextInfo:(void *)contextInfo{
if (error == nil) {
UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"提示" message:@"已存入手机相册" delegate:self cancelButtonTitle:nil otherButtonTitles:@"确定",nil];
alertView.tag = 2;
[alertView show];
}else{
UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"请去设置-隐私-照片打开允许访问" message:@"保存失败" delegate:self cancelButtonTitle:nil otherButtonTitles:@"确定", nil];
alertView.tag = 3;
[alertView show];
}
}
#pragma mark uialertview deleagate
-(void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex{
if (buttonIndex == 0 && alertView.tag ==1) {
UIImageWriteToSavedPhotosAlbum(_codeView.image, self, @selector(image:didFinishSavingWithError:contextInfo:), nil);
}else if(buttonIndex == 0 && alertView.tag==3){
//打开设置-隐私-照片
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:UIApplicationOpenSettingsURLString]];
}
}
iOS-保存图片到相册的更多相关文章
- IOS 保存图片至相册
IOS 保存图片至相册 应用中有时我们会有保存图片的需求,如利用UIImagePickerController用IOS设备内置的相机拍照,或是有时我们在应用程序中利用UIKit的 UIGraphi ...
- iOS保存图片到相册崩溃
项目迭代开发的过程中,有用户反映保存图片到相册崩溃,最终自己测试出,在iOS11以下的手机正常保存,而iOS11之后的手机则会出现反映的问题.打印错误信息如下: This app has crashe ...
- IOS UIImagePickerController 保存图片到 相册
// 异步下载图片 dispatch_queue_t queue =dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT,0); disp ...
- iOS开发——实用篇Swift篇&保存图片到相册
保存图片到相册 最近在深入的学习关于swift相关技术,虽然海做不出什么好的东西,但是感觉收获不少,相信总有一样能用到,所以就总结了一下,希望大家喜欢! 1.OC中的写法 在OC中,我们需要保存图片到 ...
- iOS摄像头和相册-UIImagePickerController常用操作
在一些应用中,我们需要用到iOS设备的摄像头进行拍照,视频.并且从相册中选取我们需要的图片或者视频. 关于iOS摄像头和相册的应用,可以使用UIImagePickerController类来完成控制. ...
- iOS摄像头和相册-UIImagePickerController-浅析
转载自:http://blog.sina.com.cn/s/blog_7b9d64af0101cfd9.html 在一些应用中,我们需要用到iOS设备的摄像头进行拍照,视频.并且从相册中选取我们需要的 ...
- ios中从相册:相机中获取图片信息
ios中从相册/相机中获取图片信息 从相册中获取图片的信息 UIImagePickerController *imgPickView = [[UIImagePickerController alloc ...
- iOS摄像头和相册-UIImagePickerController-浅析(转)
iOS摄像头和相册-UIImagePickerController-浅析(转) 转自: http://blog.sina.com.cn/s/blog_7b9d64af0101cfd9.html 在一些 ...
- ios中摄像头/相册获取图片压缩图片上传服务器方法总结
本文章介绍了关于ios中摄像头/相册获取图片,压缩图片,上传服务器方法总结,有需要了解的同学可以参考一下下. 这几天在搞iphone上面一个应用的开发,里面有需要摄像头/相册编程和图片上传的问 ...
- iOS摄像头和相册(转)
iOS摄像头和相册iOS 获取图片有三种方法1. 直接调用摄像头拍照 2. 从相册中选择 3. 从图库中选择 UIImagePickerController 是系统提供的用来获取图片和视频的接口: 用 ...
随机推荐
- c++对象模型和RTTI(runtime type information)
在前面已经探讨过了虚继承对类的大小的影响,这次来加上虚函数和虚继承对类的大小的影响. 先来回顾一下之前例子的代码: #include <iostream> using namespace ...
- Java8-Synchronized-No.01
import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; import java.util ...
- [ES2019] Represent Collision-free String Constants as Symbols in JavaScript
ES2019 introduces the Symbol.prototype.description property. In this lesson, we'll learn why this pr ...
- java web项目为什么我们要放弃jsp?(转)
前戏: 以前的项目大多数都是java程序猿又当爹又当妈,又搞前端(ajax/jquery/js/html/css等等),又搞后端(java/mysql/Oracle等等). 随着时代的发展,渐渐的许多 ...
- String.getBytes()方法中的中文编码问题(转)
String的getBytes()方法是得到一个系统默认的编码格式的字节数组getBytes("utf-8") 得到一个UTF-8格式的字节数组 把String转换成bytes, ...
- 第2组 Alpha冲刺(3/4)
17-材料-黄智(252342126) 22:10:46 队名:十一个憨批 组长博客 作业博客 组长黄智 过去两天完成的任务:写博客,复习C语言 GitHub签入记录 接下来的计划:构思游戏实现 还剩 ...
- SpringMVC 指定404、500错误页面
1.在web.xml中追加 <error-page> <error-code>404</error-code> <location>/404</l ...
- YouTube 网站的架构演进——阅读心得
基础平台 Apache Python Linux(SuSe) MySQL psyco,一个动态的Python到C的编译器 lighttpd代替Apache做视频播放 状态 支持每天超过5亿的视频点击量 ...
- centos7 设置 防火墙 开机自启
CentOS 7.0默认使用的是firewall作为防火墙,之前版本是使用iptables. 1.设置firewall开机启动 systemctl enable firewalld 2.禁止firew ...
- 【转】netty4.1.32 pipeline的添加顺序和执行顺序
原文:https://www.cnblogs.com/ruber/p/10186571.html 本文只想讨论一下pipeline的执行顺序问题,因为这个搞不明白就不知道先添加编码还是解码,是不是可以 ...