长按保存图片到本地
2015-10-26 12:12
232 查看
//创建UILongPressGestureRecognizer
UILongPressGestureRecognizer
*longPG = [[UILongPressGestureRecognizeralloc]initWithTarget:selfaction:@selector(longAction:)
];
[self
addGestureRecognizer:longPG];
}
//长按触发的方法
-(void)longAction:(UILongPressGestureRecognizer
*)longPG
{
if (longPG.state
==
UIGestureRecognizerStateBegan)
{
//创建UIAlertView对象
UIAlertView *alert = [[UIAlertView
alloc]initWithTitle:@"提示"
message:@"是否保存图片到本地"
delegate:self
cancelButtonTitle:@"取消"
otherButtonTitles:@"确定",
nil];
//调用show方法
[alert
show];
//释放
[alert
release];
}
}
- (void)alertView:(UIAlertView
*)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
{
if (buttonIndex ==
1) {
//UIImage写入本地的方法
UIImageWriteToSavedPhotosAlbum(self.photo.image,
nil,
nil,
nil);
//创建UIAlertView对象
UIAlertView *alert = [[UIAlertView
alloc]initWithTitle:@"提示"
message:@"图片已保存成功"
delegate:self
cancelButtonTitle:nil
otherButtonTitles:
nil];
//调用show方法
[alert
show];
//释放
[alert
release];
dispatch_after(dispatch_time(DISPATCH_TIME_NOW,
(int64_t)(1.0f
*
NSEC_PER_SEC)),
dispatch_get_main_queue(), ^{
[alert
dismissWithClickedButtonIndex:0
animated:YES];
});
}
}
UILongPressGestureRecognizer
*longPG = [[UILongPressGestureRecognizeralloc]initWithTarget:selfaction:@selector(longAction:)
];
[self
addGestureRecognizer:longPG];
}
//长按触发的方法
-(void)longAction:(UILongPressGestureRecognizer
*)longPG
{
if (longPG.state
==
UIGestureRecognizerStateBegan)
{
//创建UIAlertView对象
UIAlertView *alert = [[UIAlertView
alloc]initWithTitle:@"提示"
message:@"是否保存图片到本地"
delegate:self
cancelButtonTitle:@"取消"
otherButtonTitles:@"确定",
nil];
//调用show方法
[alert
show];
//释放
[alert
release];
}
}
- (void)alertView:(UIAlertView
*)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
{
if (buttonIndex ==
1) {
//UIImage写入本地的方法
UIImageWriteToSavedPhotosAlbum(self.photo.image,
nil,
nil,
nil);
//创建UIAlertView对象
UIAlertView *alert = [[UIAlertView
alloc]initWithTitle:@"提示"
message:@"图片已保存成功"
delegate:self
cancelButtonTitle:nil
otherButtonTitles:
nil];
//调用show方法
[alert
show];
//释放
[alert
release];
dispatch_after(dispatch_time(DISPATCH_TIME_NOW,
(int64_t)(1.0f
*
NSEC_PER_SEC)),
dispatch_get_main_queue(), ^{
[alert
dismissWithClickedButtonIndex:0
animated:YES];
});
}
}
相关文章推荐
- 使用static与const关键字时需要掌握的知识
- Oracle数据库sys为什么只能以sysdba登录
- 新一代服务器性能测试工具Gatling
- 机器学习中的范数规则化之(一)L0、L1与L2范数
- linux查看服务器负载 load average
- codeforces 591 C. Median Smoothing
- 项目里project.properties文件 android 通过eclipse混淆代码 打包 加入了易支付
- dubbo架构详解
- 全局光照技术解析Global Illumination Explained
- 使用CocoaPods下载第三方库时的Podfile配置问题
- 【MSP430 编译器使用经验】+ IAR 环境下的函数定位加载(分散加载)方法
- TEMP_FAILURE_RETRY,__extension,MSG_NOSIGNAL
- 观察者设计模式
- Cryengine 3新的全局光照算法简介
- SLAM: 基于运动和视觉里程方法的实时三维构建:Map-Management/坐标系转换
- 如何把sqlserver数据迁移到mysql数据库及需要注意事项
- Unity 5 中的全局光照技术详解
- sql查询含有关键字的坑
- Python点点滴滴积累---getopt使用(详解)
- 为HTML添加图片登录按钮