一款图片,视频选择类库
- 增加了一个基于YYWebImage框架封装的图片浏览器 XMNPhotoBrowser -- 强烈推荐学习下ibireme大神的其他框架
- 修复iOS8以下崩溃bug
- 去除获取图片时,图片按照创建时间排序的功能
- 增加了类似QQ手势拖动发送图片功能
- 2016-07-14 修复pickingVideoEnable属性 区分是否选择图片,或者视频
- 修复选择视频时 谓词过滤崩溃bug 感谢suyongmaozhao
- 修复了首次提示授权选择后 页面不更新问题
- 去除了拖动发送功能
- 增加了类似QQ的选择stick功能
- 修复XMNPhotoPicker 选择最大数量提示不正确
- 修复pods引用后没有找到xib文件
- 修复自定义导航栏导致底部bottomBar位置不正确问题
- 一款图片,视频选择类库
- 支持直接显示相册选择
- 支持类似QQ方式Sheet选择
- iOS8+支持动态监测PhotoLibrary变化
- 支持预览图片,预览视频
-
. pods使用 pod 'XMNPhotoPickerFramework'
-
. 直接引用
- 命令行下
git clone https://github.com/ws00801526/ XMNPhotoPickerFramework.git
- 拖动
XMNPhotoPickerFramework
到你的工程内 - 导入头文件
XMNPhotoPickerFramework.h
即可 - 具体用法,请参考demo
- 命令行下
- (void)_showPhotoPickerC {
//1.初始化一个XMNPhotoPickerController
XMNPhotoPickerController *photoPickerC = [[XMNPhotoPickerController alloc] initWithMaxCount:9 delegate:nil];
//3.取消注释下面代码,使用代理方式回调,代理方法参考XMNPhotoPickerControllerDelegate
// photoPickerC.photoPickerDelegate = self;
//3..设置选择完照片的block 回调
__weak typeof(*&self) wSelf = self;
[photoPickerC setDidFinishPickingPhotosBlock:^(NSArray<UIImage *> *images, NSArray<XMNAssetModel *> *assets) {
__weak typeof(*&self) self = wSelf;
NSLog(@"picker images :%@ \n\n assets:%@",images,assets);
//!!!如果需要自定义大小的图片 使用下面方法
// [[XMNPhotoManager sharedManager] getThumbnailWithAsset:<# asset in assets #> size:<# your size #> completionBlock:^(UIImage * _Nullable image) {
//
// }];
self.assets = [assets copy];
[self.collectionView reloadData];
//XMNPhotoPickerController 确定选择,并不会自己dismiss掉,需要自己dismiss
[self dismissViewControllerAnimated:YES completion:nil];
}];
//4.设置选择完视频的block回调
[photoPickerC setDidFinishPickingVideoBlock:^(UIImage *coverImage, XMNAssetModel * asset) {
__weak typeof(*&self) self = wSelf;
NSLog(@"picker image :%@\n\n asset:%@\n\n",coverImage,asset);
self.assets = @[asset];
[self.collectionView reloadData];
//XMNPhotoPickerController 确定选择,并不会自己dismiss掉,需要自己dismiss
[self dismissViewControllerAnimated:YES completion:nil];
}];
//5.设置用户取消选择的回调 可选
[photoPickerC setDidCancelPickingBlock:^{
NSLog(@"photoPickerC did Cancel");
//此处不需要自己dismiss
}];
//6. 显示photoPickerC
[self presentViewController:photoPickerC animated:YES completion:nil];
}
- (void)_showPhotoPicker {
//1. 推荐使用XMNPhotoPicker 的单例
//2. 设置选择完照片的block回调
[[XMNPhotoPicker sharePhotoPicker] setDidFinishPickingPhotosBlock:^(NSArray<UIImage *> *images, NSArray<XMNAssetModel *> *assets) {
NSLog(@"picker images :%@ \n\n assets:%@",images,assets);
self.assets = [assets copy];
[self.collectionView reloadData];
}];
//3. 设置选择完视频的block回调
[[XMNPhotoPicker sharePhotoPicker] setDidFinishPickingVideoBlock:^(UIImage * image, XMNAssetModel *asset) {
NSLog(@"picker video :%@ \n\n asset :%@",image,asset);
self.assets = @[asset];
[self.collectionView reloadData];
}];
//4. 显示XMNPhotoPicker
[[XMNPhotoPicker sharePhotoPicker] showPhotoPickerwithController:self animated:YES];
}