iOS之修改项目BUG之旅--(三)
来源:互联网 发布:尼采著作全集 知乎 编辑:程序博客网 时间:2024/06/06 05:04
问题:在一个图片浏览器放大当前图片的时候,点击删除,出现提示框是否删除图片
解决方案:
一.使用UIAlertView解决(ps:这是ios8以前的方法)
//点击事件- (void)photoBrowserButtons:(CHPhotoBrowserButtons *)buttons deleteBtn:(UIButton *)deleteBtn {UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"提示" message:@"你确定要删除照片吗?" delegate:self cancelButtonTitle:@"取消" otherButtonTitles: @"确定",nil];[alert show];}//UIAlertViewDelegate协议实现的方法-(void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex{ if (buttonIndex == 1) { [CHPhotoScrollHttpTool deletedFamilyPhoto:self.photos[self.currentPhotoIndex] success:^{ [MBProgressHUD showSuccess:nil]; [[NSNotificationCenter defaultCenter] postNotificationName:NOTIFICATION_DIDDETLE_PIC object:nil]; [self mcancel:nil]; } failure:^{ [MBProgressHUD showError:nil]; [self mcancel:nil]; }];[buttonsView hide];isShow = NO; }}
二.使用UIAlertController(ps:ios8以后使用的方法)
//点击事件- (void)photoBrowserButtons:(CHPhotoBrowserButtons *)buttons deleteBtn:(UIButton *)deleteBtn {//创建UIAlertController UIAlertController *alertController = [UIAlertController alertControllerWithTitle:@"提示" message:@"你确定要删除照片吗?" preferredStyle:(UIAlertControllerStyleAlert)];//创建确定按钮 UIAlertAction *defult = [UIAlertAction actionWithTitle:@"确定" style:(UIAlertActionStyleDefault) handler:^(UIAlertAction * action) { NSLog(@"点击确定后执行的事件"); }];//创建取消按钮 UIAlertAction *cancel = [UIAlertAction actionWithTitle:@"取消" style:(UIAlertActionStyleCancel) handler:nil];//将UIAlertAction添加到UIALertController [alertController addAction:defult]; [alertController addAction:cancel];//获取当前ViewController,并present弹出模态UIAlertController//注意,这里presentViewController前面的对象必须为ViewController [[self getPresentedViewController] presentViewController:alertController animated:YES completion:nil]; }//获取当前屏幕中present出来的Viewcontroller- (UIViewController *)getPresentedViewController{ UIViewController *appRootVC = [UIApplication sharedApplication].keyWindow.rootViewController; UIViewController *topVC = appRootVC; if (topVC.childViewControllers.count>0) { topVC = [topVC.childViewControllers lastObject]; } return topVC;}
1 0
- iOS之修改项目BUG之旅--(三)
- iOS之修改项目BUG之旅--(一)
- iOS之修改项目BUG之旅--(二)
- iOS之修改项目BUG之旅--(四)
- iOS之修改项目BUG之旅--(五)
- iOS之修改项目BUG之旅--(六)
- iOS之修改项目BUG之旅--(七)
- NetCms修改之三:相关新闻的Bug及其修正
- bug之旧项目
- iOS开发笔记之二十三——一个delegate没有更新引起的bug(bug总结三)
- IOS 菜鸟笔记 之 项目 三
- 今日之学-bug修改
- IOS开发之常见bug
- iOS开发之Bug汇总
- 第35篇 IOS-WebRTC BUG处理(三)之问题图片导入及本地运行两个nodejs
- 基于ffmpeg的开源项目havlena,源码修改系列一之 修复bug
- 修改bug的漫长之路
- iOS学习之——如何修改项目名称(APP名字)
- 线性表的基本概念
- 非标准武术擂台1V1机器人示例程序
- txt导入到mySQL
- C++作业5
- 表单实现表单自动生成工厂
- iOS之修改项目BUG之旅--(三)
- C++作业5
- [一起学Hive]之十二-Hive SQL的优化
- 设计模式C++学习笔记之十七(Chain of Responsibility责任链模式)
- UIRectEdgeNone
- sql server中select语句需要申请的锁
- MAC OSX 的 spotlight 、mds_stores 关闭
- Linux-35-liunx基础重要命令12(L005-17)
- Android快速实现微信支付(真的!很快!)