(更新了)QQ图片选择器----支持多选、选原图和视频的图片选择器,同时有预览功能
查看次数:4268
下载次数:722
上传时间:2016-08-31
大小:170 B
手动导入:将项目中的HX_ImagerPicker此文件夹拽入项目中,导入头文件:#import "HX_AddPhotoView.h"
例子:
在有导航栏的控制器里需要设置设个这两个属性
self.automaticallyAdjustsScrollViewInsets = NO;
self.navigationController.navigationBar.translucent = YES;
当一个界面有两个选择器的时候最好设置约束
// 只选择照片
HX_AddPhotoView *addPhotoView = [[HX_AddPhotoView alloc] initWithMaxPhotoNum:9 WithSelectType:SelectPhoto];
addPhotoView.lineNum = 3;
addPhotoView.delegate = self;
addPhotoView.backgroundColor = [UIColor whiteColor];
addPhotoView.frame = CGRectMake(5, 150, width - 10, 0);
[self.view addSubview:addPhotoView];
/** 当前选择的个数 */
addPhotoView.selectNum;
// 当选择类型为 SelectPhoto 或 SelectPhotoAndVideo 时 请用这个block
[addPhotoView setSelectPhotos:^(NSArray *photos, BOOL iforiginal) {
iforiginal 是否原图
[photos enumerateObjectsUsingBlock:^(ALAsset *asset, NSUInteger idx, BOOL * _Nonnull stop) {
// 缩略图
// UIImage *image = [UIImage imageWithCGImage:[asset aspectRatioThumbnail]];
// 原图
// CGImageRef fullImage = [[asset defaultRepresentation] fullResolutionImage];
// url
// NSURL *url = [[asset defaultRepresentation] url];
}];
}];
// 只选择视频 内部已经强制性的只能选择一个
HX_AddPhotoView *addVideoView = [[HX_AddPhotoView alloc] initWithMaxPhotoNum:1 WithSelectType:SelectVideo];
// 当选择类型为 SelectVideo 时 请用这个block
[addVideoView setSelectVideo:^(NSArray *video) {
[video enumerateObjectsUsingBlock:^(ALAsset *asset, NSUInteger idx, BOOL * _Nonnull stop) {} ];
// 代理---- 当每行个数超过最大限制的个数时 此方法就会更新AddPhotoView的高度
- (void)updateViewFrame:(CGRect)frame
{
[self.view layoutSubviews];
}
具体代码看请下载项目
发现的哪里有不好或不对的地方麻烦请联系我,大家一起讨论一起学习进步...
QQ : 294005139
如果觉得代码写的比较乱的 请谅解哈, 毕竟我最开始只是一个外行人 才学ios 和 计算机 才4个月 .....
收藏