Commit c9c9e3d3 authored by banchichen's avatar banchichen

新增对所有照片相册的适配

parent 95dfbaed
...@@ -5,6 +5,12 @@ ...@@ -5,6 +5,12 @@
#import <UIKit/UIKit.h> #import <UIKit/UIKit.h>
/*
此类来源于DeveloperLx的优秀开源项目:LxGridView
github链接:https://github.com/DeveloperLx/LxGridView
我对这个类的代码做了一些修改;
感谢DeveloperLx的优秀代码~
*/
@interface LxGridViewFlowLayout : UICollectionViewFlowLayout @interface LxGridViewFlowLayout : UICollectionViewFlowLayout
......
...@@ -17,6 +17,13 @@ CG_INLINE CGPoint CGPointOffset(CGPoint point, CGFloat dx, CGFloat dy) ...@@ -17,6 +17,13 @@ CG_INLINE CGPoint CGPointOffset(CGPoint point, CGFloat dx, CGFloat dy)
return CGPointMake(point.x + dx, point.y + dy); return CGPointMake(point.x + dx, point.y + dy);
} }
/*
此类来源于DeveloperLx的优秀开源项目:LxGridView
github链接:https://github.com/DeveloperLx/LxGridView
我对这个类的代码做了一些修改;
感谢DeveloperLx的优秀代码~
*/
@interface LxGridViewFlowLayout () <UIGestureRecognizerDelegate> @interface LxGridViewFlowLayout () <UIGestureRecognizerDelegate>
@property (nonatomic,readonly) id<LxGridViewDataSource> dataSource; @property (nonatomic,readonly) id<LxGridViewDataSource> dataSource;
......
...@@ -56,7 +56,7 @@ ...@@ -56,7 +56,7 @@
PHFetchResult *smartAlbums = [PHAssetCollection fetchAssetCollectionsWithType:PHAssetCollectionTypeSmartAlbum subtype:PHAssetCollectionSubtypeSmartAlbumUserLibrary options:nil]; PHFetchResult *smartAlbums = [PHAssetCollection fetchAssetCollectionsWithType:PHAssetCollectionTypeSmartAlbum subtype:PHAssetCollectionSubtypeSmartAlbumUserLibrary options:nil];
for (PHAssetCollection *collection in smartAlbums) { for (PHAssetCollection *collection in smartAlbums) {
if ([collection.localizedTitle isEqualToString:@"Camera Roll"] || [collection.localizedTitle isEqualToString:@"相机胶卷"]) { if ([collection.localizedTitle isEqualToString:@"Camera Roll"] || [collection.localizedTitle isEqualToString:@"相机胶卷"] || [collection.localizedTitle isEqualToString:@"所有照片"]) {
PHFetchResult *fetchResult = [PHAsset fetchAssetsInAssetCollection:collection options:option]; PHFetchResult *fetchResult = [PHAsset fetchAssetsInAssetCollection:collection options:option];
model = [self modelWithResult:fetchResult name:collection.localizedTitle]; model = [self modelWithResult:fetchResult name:collection.localizedTitle];
if (completion) completion(model); if (completion) completion(model);
...@@ -68,7 +68,7 @@ ...@@ -68,7 +68,7 @@
if ([group numberOfAssets] < 1) return; if ([group numberOfAssets] < 1) return;
NSString *name = [group valueForProperty:ALAssetsGroupPropertyName]; NSString *name = [group valueForProperty:ALAssetsGroupPropertyName];
if ([name isEqualToString:@"Camera Roll"] || [name isEqualToString:@"相机胶卷"]) { if ([name isEqualToString:@"Camera Roll"] || [name isEqualToString:@"相机胶卷"] || [name isEqualToString:@"所有照片"]) {
model = [self modelWithResult:group name:name]; model = [self modelWithResult:group name:name];
if (completion) completion(model); if (completion) completion(model);
*stop = YES; *stop = YES;
......
...@@ -69,7 +69,7 @@ static CGSize AssetGridThumbnailSize; ...@@ -69,7 +69,7 @@ static CGSize AssetGridThumbnailSize;
self.view.backgroundColor = [UIColor whiteColor]; self.view.backgroundColor = [UIColor whiteColor];
self.navigationItem.title = _model.name; self.navigationItem.title = _model.name;
self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"取消" style:UIBarButtonItemStylePlain target:self action:@selector(cancel)]; self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"取消" style:UIBarButtonItemStylePlain target:self action:@selector(cancel)];
if ([_model.name isEqualToString:@"相机胶卷"] || [_model.name isEqualToString:@"Camera Roll"]) { if ([_model.name isEqualToString:@"相机胶卷"] || [_model.name isEqualToString:@"Camera Roll"] || [_model.name isEqualToString:@"所有照片"] ) {
[[TZImageManager manager] getAssetsFromFetchResult:_model.result allowPickingVideo:_tzImagePickerVc.allowPickingVideo allowPickingImage:_tzImagePickerVc.allowPickingImage completion:^(NSArray<TZAssetModel *> *models) { [[TZImageManager manager] getAssetsFromFetchResult:_model.result allowPickingVideo:_tzImagePickerVc.allowPickingVideo allowPickingImage:_tzImagePickerVc.allowPickingImage completion:^(NSArray<TZAssetModel *> *models) {
_photoArr = [NSMutableArray arrayWithArray:models]; _photoArr = [NSMutableArray arrayWithArray:models];
[self initSubviews]; [self initSubviews];
...@@ -111,7 +111,7 @@ static CGSize AssetGridThumbnailSize; ...@@ -111,7 +111,7 @@ static CGSize AssetGridThumbnailSize;
_collectionView.alwaysBounceHorizontal = NO; _collectionView.alwaysBounceHorizontal = NO;
if (iOS7Later) _collectionView.contentInset = UIEdgeInsetsMake(0, 0, 0, 2); if (iOS7Later) _collectionView.contentInset = UIEdgeInsetsMake(0, 0, 0, 2);
_collectionView.scrollIndicatorInsets = UIEdgeInsetsMake(0, 0, 0, -2); _collectionView.scrollIndicatorInsets = UIEdgeInsetsMake(0, 0, 0, -2);
if ([_model.name isEqualToString:@"相机胶卷"] || [_model.name isEqualToString:@"Camera Roll"] ) { if ([_model.name isEqualToString:@"相机胶卷"] || [_model.name isEqualToString:@"Camera Roll"] || [_model.name isEqualToString:@"所有照片"] ) {
_collectionView.contentSize = CGSizeMake(self.view.tz_width, ((_model.count + 4) / 4) * self.view.tz_width); _collectionView.contentSize = CGSizeMake(self.view.tz_width, ((_model.count + 4) / 4) * self.view.tz_width);
} else { } else {
_collectionView.contentSize = CGSizeMake(self.view.tz_width, ((_model.count + 3) / 4) * self.view.tz_width); _collectionView.contentSize = CGSizeMake(self.view.tz_width, ((_model.count + 3) / 4) * self.view.tz_width);
...@@ -283,7 +283,7 @@ static CGSize AssetGridThumbnailSize; ...@@ -283,7 +283,7 @@ static CGSize AssetGridThumbnailSize;
#pragma mark - UICollectionViewDataSource && Delegate #pragma mark - UICollectionViewDataSource && Delegate
- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section { - (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section {
if ([_model.name isEqualToString:@"相机胶卷"] || [_model.name isEqualToString:@"Camera Roll"]) { if ([_model.name isEqualToString:@"相机胶卷"] || [_model.name isEqualToString:@"Camera Roll"] || [_model.name isEqualToString:@"所有照片"] ) {
if (_tzImagePickerVc.allowPickingImage) { if (_tzImagePickerVc.allowPickingImage) {
return _photoArr.count + 1; return _photoArr.count + 1;
} }
...@@ -431,7 +431,7 @@ static CGSize AssetGridThumbnailSize; ...@@ -431,7 +431,7 @@ static CGSize AssetGridThumbnailSize;
- (void)scrollCollectionViewToBottom { - (void)scrollCollectionViewToBottom {
if (_shouldScrollToBottom && _photoArr.count > 0) { if (_shouldScrollToBottom && _photoArr.count > 0) {
NSInteger item = _photoArr.count - 1; NSInteger item = _photoArr.count - 1;
if ([_model.name isEqualToString:@"相机胶卷"] || [_model.name isEqualToString:@"Camera Roll"]) { if ([_model.name isEqualToString:@"相机胶卷"] || [_model.name isEqualToString:@"Camera Roll"] || [_model.name isEqualToString:@"所有照片"] ) {
if (_tzImagePickerVc.allowPickingImage) { if (_tzImagePickerVc.allowPickingImage) {
item += 1; item += 1;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment