这是一个 iOS 上的 MGPhotoCollectionView 视图。
这是一个仿照 QQ 空间上传照片样式封装的选择相册示例,并进行了部分扩展,点击可放大查看大图。1. 可以根据需求创建几列 2. 使用通知代理 (delegate) 或 block 进行删除、点击查看(具体方法请查看示例)
建议及意见请联系-> QQ: 964195787 邮箱:[email protected] 谢谢!
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]; };
self.collectionView.ReturnClickDeletePhoto = ^(MGPhotoCollectionView * collectionView, NSMutableArray *photoArray, NSInteger nextIndex){ if (photoArray.count > 0) {
}
} };
// =========== MGPhotoCollectionViewDelegate ========
-(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; }]; }
-(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{ } }
-(void)collectionView:(MGPhotoCollectionView *)collectionView isDeleteState:(BOOL)state photoArray:(NSMutableArray *)photoArray {
}
/** 点击删除按钮时 返回数据源及下一个按钮
@param collectionView MGPhotoCollectionView对象 @param photoArray 数据源数组 @param nextIndex 下一个数组 / -(void)collectionView:(MGPhotoCollectionView *)collectionView photoArray:(NSMutableArray )photoArray nextIndex:(NSInteger)nextIndex {
}