1.Privacy - Photo Library Usage Description 权限写入info.plist
2.自定义UICollectionViewController
#import <UIKit/UIKit.h>
#import <Photos/Photos.h>
#import "XMPickImageCollectionViewCell.h"
#import "XMPublishContentVideoController.h"
NS_ASSUME_NONNULL_BEGIN
@interface XMPickImageViewController : UICollectionViewController
@property (nonatomic,strong) NSMutableArray *photoArray;
@property (nonatomic,strong) NSMutableDictionary *imageDic;
@property (nonatomic,strong) NSMutableDictionary *vedioDic;
@end
NS_ASSUME_NONNULL_END
#import "XMPickImageViewController.h"
@interface XMPickImageViewController ()<UICollectionViewDelegate>
@end
@implementation XMPickImageViewController
- (void)viewDidLoad {
[super viewDidLoad];
self.photoArray = [[NSMutableArray alloc] init];
PHFetchResult<PHAsset *> *fetchResult = [PHAsset fetchAssetsWithMediaType:PHAssetMediaTypeImage options:nil];
self.imageDic = [[NSMutableDictionary alloc] init];
PHImageManager *imageManger = [PHImageManager defaultManager];
for (PHAsset *asset in fetchResult) {
[imageManger requestImageForAsset:asset targetSize:CGSizeMake(110, 110) contentMode:PHImageContentModeDefault options:nil resultHandler:^(UIImage * _Nullable result, NSDictionary * _Nullable info) {
[self.photoArray addObject:result];
}];
}
fetchResult = [PHAsset fetchAssetsWithMediaType:PHAssetMediaTypeVideo options:nil];
for (PHAsset *