MGPhotoCollectionView 1.0.8

MGPhotoCollectionView 1.0.8

测试测试
语言语言 Obj-CObjective C
许可 MIT
发布最后发布2017年1月

华&梅 维护。



  • _GaoFei

这是一个 iOS 上的 MGPhotoCollectionView 视图。

这是一个仿照 QQ 空间上传照片样式封装的选择相册示例,并进行了部分扩展,点击可放大查看大图。1. 可以根据需求创建几列 2. 使用通知代理 (delegate) 或 block 进行删除、点击查看(具体方法请查看示例)

安装方法

1. 从 GitHub 网址:

https://github.com/gdhGaoFei/MGPhotoCollectionView.git

进行下载

将要 #import "MGPhotoCollectionView.h"、

#import "MGPhotoViewController.h"(不需要点击放大,可以不导入此头文件),导入即可。

建议及意见请联系-> QQ: 964195787 邮箱:[email protected] 谢谢!

使用方法: 支持两种创建方式 1. 纯代码手写 2. 使用 Storyboard/xib 进行创建。使用示例在 https://github.com/gdhGaoFei/MGPhotoCollectionView.git 上已列出,欢迎查看使用。

1. 使用 block 方法

点击其他方面的按钮

self.collectionView.ReturnClickIndexAndArray = ^(NSInteger index, NSArray * photoArray, MGPhotoCollectionView * collectionView){ if (photoArray.count > 0) { MGPhotoViewController * vc = [[MGPhotoViewController alloc] init]; vc.dataArray = photoArray; vc.clickIndex = index; [self presentViewController:vc animated:YES completion:^{

}]; }else{ } };

点击添加照片按钮

self.collectionView.ReturnClickAddPhoto = ^(NSMutableArray * photoArray, MGPhotoCollectionView * collectionView){ [self loadCreateAddPhotoArray:photoArray]; };

点击删除按钮时 block 返回

self.collectionView.ReturnClickDeletePhoto = ^(MGPhotoCollectionView * collectionView, NSMutableArray *photoArray, NSInteger nextIndex){ if (photoArray.count > 0) {

}

} };

2. 使用通知代理

// =========== MGPhotoCollectionViewDelegate ========

========= 1. 添加图片

-(void)collectionView:(MGPhotoCollectionView *)collectionView addPhotoArray:(NSMutableArray *)photoArray { [self.daimaCurrentPhotoArray removeAllObjects]; [self.daimaCurrentPhotoArray addObjectsFromArray:photoArray]; [[GDHGlobalUtil ShareGDHGlobalUtil] TransferCameraWithViewController:self ImageBlock:^(UIImage *image) { MGPhotoModel * photo = [MGPhotoModel CreateModelWithIcon:@"" withType:2 withImage:image withIsDelete:NO withIsModelType:NO]; [self.daimaCurrentPhotoArray addObject:photo]; self.daimaCollectionView.dataArray = self.daimaCurrentPhotoArray; }]; }

========= 2. 点击图片

-(void)collectionView:(MGPhotoCollectionView *)collectionView clickIndex:(NSInteger)index photoArray:(NSMutableArray *)photoArray { if (photoArray.count > 0) { MGPhotoViewController * vc = [[MGPhotoViewController alloc] init]; vc.dataArray = photoArray; vc.clickIndex = index; [self presentViewController:vc animated:YES completion:^{

}]; }else{ } }

========== 3. 是否处于删除状态

-(void)collectionView:(MGPhotoCollectionView *)collectionView isDeleteState:(BOOL)state photoArray:(NSMutableArray *)photoArray {

}

========= 4. 点击删除按钮时 返回数据源及下一个按钮

/** 点击删除按钮时 返回数据源及下一个按钮

@param collectionView MGPhotoCollectionView对象 @param photoArray 数据源数组 @param nextIndex 下一个数组 / -(void)collectionView:(MGPhotoCollectionView *)collectionView photoArray:(NSMutableArray )photoArray nextIndex:(NSInteger)nextIndex {

}