// 每一个图片控件对象, 对一一对应 KNPhotoItems ,再将多个KNPhotoItems 对象放入数组 KNPhotoItems *items = [[KNPhotoItems alloc] init]; items.url = [urlArr[i] stringByReplacingOccurrencesOfString:@"thumbnail" withString:@"bmiddle"]; items.sourceView = imageView; KNPhotoBrower *photoBrower = [[KNPhotoBrower alloc] init]; photoBrower.itemsArr = [_itemsArray copy];// KNPhotoItems对象的数组 photoBrower.currentIndex = tap.view.tag;// 当前点击的哪个图片 photoBrower.actionSheetArr = [self.actionSheetArray mutableCopy];//设置 ActionSheet的选项 [photoBrower present];// 显示
/* PhotoBrower 即将消失 */ - (void)photoBrowerWillDismiss; /* PhotoBrower 右上角按钮的点击 */ - (void)photoBrowerRightOperationActionWithIndex:(NSInteger)index; /* PhotoBrower 保存图片是否成功 */ - (void)photoBrowerWriteToSavedPhotosAlbumStatus:(BOOL)success;
/** * 是否需要右上角的按钮. Default is YES; */ @property (nonatomic, assign) BOOL isNeedRightTopBtn; /** * 是否需要 顶部 1 / 9 控件 ,Default is YES */ @property (nonatomic, assign) BOOL isNeedPageNumView; /** * 是否需要 底部 UIPageControl, Default is NO */ @property (nonatomic, assign) BOOL isNeedPageControl; /** * 存放 ActionSheet 弹出框的内容 :NSString类型 */ @property (nonatomic, strong) NSMutableArray *actionSheetArr;
#pragma mark - 右上角 按钮的点击
- (void)operationBtnIBAction{
__weak typeof(self) weakSelf = self;
if(_actionSheetArr.count != 0){ // 如果是自定义的 选项
KNActionSheet *actionSheet = [[KNActionSheet alloc] initWithCancelBtnTitle:nil destructiveButtonTitle:nil otherBtnTitlesArr:[_actionSheetArr copy] actionBlock:^(NSInteger buttonIndex) {
// 让代理知道 是哪个按钮被点击了
if([weakSelf.delegate respondsToSelector:@selector(photoBrowerRightOperationActionWithIndex:)]){
[weakSelf.delegate photoBrowerRightOperationActionWithIndex:buttonIndex];
}
#warning 如果传入的 ActionSheetArr 有下载图片这一选项. 则在这里调用和下面一样的方法 switch.....,如果没有下载图片,则通过代理方法去实现... 目前不支持删除功能
}];
[actionSheet show];
}else{
KNActionSheet *actionSheet = [[KNActionSheet alloc] initWithCancelBtnTitle:nil destructiveButtonTitle:nil otherBtnTitlesArr:@[@"保存图片",@"转发微博",@"赞"] actionBlock:^(NSInteger buttonIndex) {
// 让代理知道 是哪个按钮被点击了
if([weakSelf.delegate respondsToSelector:@selector(photoBrowerRightOperationActionWithIndex:)]){
[weakSelf.delegate photoBrowerRightOperationActionWithIndex:buttonIndex];
}
switch (buttonIndex) {
case 0:{
SDWebImageManager *mgr = [SDWebImageManager sharedManager];
KNPhotoItems *items = _itemsArr[_currentIndex];
if(![mgr diskImageExistsForURL:[NSURL URLWithString:items.url]]){
[[KNToast shareToast] initWithText:@"图片需要下载完成"];
return ;
}else{
UIImage *image = [[mgr imageCache] imageFromDiskCacheForKey:items.url];
dispatch_async(dispatch_get_main_queue(), ^{
UIImageWriteToSavedPhotosAlbum(image, self, @selector(image:didFinishSavingWithError:contextInfo:), NULL);
});
}
}
default:
break;
}
}];
[actionSheet show];
}
}
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有