|
|
@@ -174,7 +174,7 @@
|
|
|
*/
|
|
|
- (void)setupGroupView {
|
|
|
AJPhotoGroupView *photoGroupView = [[AJPhotoGroupView alloc] init];
|
|
|
- photoGroupView.assetsFilter = self.assetsFilter;
|
|
|
+ //photoGroupView.assetsFilter = self.assetsFilter;
|
|
|
photoGroupView.my_delegate = self;
|
|
|
[self.view insertSubview:photoGroupView belowSubview:self.navBarBGView];
|
|
|
self.photoGroupView = photoGroupView;
|
|
|
@@ -183,11 +183,17 @@
|
|
|
|
|
|
[self.photoGroupView setupGroup];
|
|
|
|
|
|
+ NSInteger maxCount = 6;
|
|
|
+
|
|
|
+ if(self.photoGroupView.albumGroups.count < maxCount){
|
|
|
+ maxCount = self.photoGroupView.albumGroups.count;
|
|
|
+ }
|
|
|
+
|
|
|
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1.0 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
|
|
|
[photoGroupView mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
make.left.mas_equalTo(0);
|
|
|
make.right.mas_equalTo(0);
|
|
|
- make.height.mas_equalTo(60.0*self.photoGroupView.groups.count);
|
|
|
+ make.height.mas_equalTo(60.0 * maxCount);
|
|
|
make.top.equalTo(self.navBarBGView.mas_bottom).offset(0.f);
|
|
|
}];
|
|
|
});
|
|
|
@@ -207,7 +213,10 @@
|
|
|
self.bgMaskView.hidden = NO;
|
|
|
self.photoGroupView.hidden = NO;
|
|
|
[UIView animateWithDuration:0.3 animations:^{
|
|
|
- //self.photoGroupView.transform = CGAffineTransformMakeTranslation(0, 360);
|
|
|
+ CGRect rect = self.photoGroupView.frame;
|
|
|
+ rect.origin.y = CGRectGetMaxY(self.navBarBGView.frame);
|
|
|
+ self.photoGroupView.frame = rect;
|
|
|
+
|
|
|
self.selectTip.transform = CGAffineTransformMakeRotation(M_PI);
|
|
|
}];
|
|
|
} else {
|
|
|
@@ -219,7 +228,10 @@
|
|
|
//[self.bgMaskView removeFromSuperview];
|
|
|
self.bgMaskView.hidden = YES;
|
|
|
[UIView animateWithDuration:0.3 animations:^{
|
|
|
- //self.photoGroupView.transform = CGAffineTransformIdentity;
|
|
|
+ CGRect rect = self.photoGroupView.frame;
|
|
|
+ rect.origin.y = -SCREEN_H;
|
|
|
+ self.photoGroupView.frame = rect;
|
|
|
+
|
|
|
self.selectTip.transform = CGAffineTransformIdentity;
|
|
|
}completion:^(BOOL finished) {
|
|
|
self.photoGroupView.hidden = YES;
|
|
|
@@ -260,43 +272,23 @@
|
|
|
|
|
|
|
|
|
#pragma mark - BoPhotoGroupViewProtocol
|
|
|
-- (void)didSelectGroup:(ALAssetsGroup *)assetsGroup {
|
|
|
- [self loadAssets:assetsGroup];
|
|
|
- [self setTitleLabelText:[assetsGroup valueForProperty:ALAssetsGroupPropertyName]];
|
|
|
+- (void)didSelectGroup:(TZAlbumModel *)model {
|
|
|
+ [self loadAssets:model];
|
|
|
+ [self setTitleLabelText:model.name];
|
|
|
[self hidenGroupView];
|
|
|
}
|
|
|
|
|
|
//加载图片
|
|
|
-- (void)loadAssets:(ALAssetsGroup *)assetsGroup {
|
|
|
+- (void)loadAssets:(TZAlbumModel *)model {
|
|
|
[self.indexPathsForSelectedItems removeAllObjects];
|
|
|
[self.assets removeAllObjects];
|
|
|
|
|
|
- //相机cell
|
|
|
- NSMutableArray *tempList = [[NSMutableArray alloc] init];
|
|
|
- //默认第一个为相机按钮
|
|
|
- //[tempList addObject:[UIImage imageWithContentsOfFile:[[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:@"BoPhotoPicker.bundle/images/BoAssetsCamera@2x.png"]]];
|
|
|
-
|
|
|
- ALAssetsGroupEnumerationResultsBlock resultsBlock = ^(ALAsset *asset, NSUInteger index, BOOL *stop) {
|
|
|
- if (asset) {
|
|
|
- [tempList addObject:asset];
|
|
|
- } else if (tempList.count > 0) {
|
|
|
- //排序
|
|
|
- NSArray *sortedList = [tempList sortedArrayUsingComparator:^NSComparisonResult(ALAsset *first, ALAsset *second) {
|
|
|
- if ([first isKindOfClass:[UIImage class]]) {
|
|
|
- return NSOrderedAscending;
|
|
|
- }
|
|
|
- id firstData = [first valueForProperty:ALAssetPropertyDate];
|
|
|
- id secondData = [second valueForProperty:ALAssetPropertyDate];
|
|
|
- return [secondData compare:firstData];//降序
|
|
|
- }];
|
|
|
- [self.assets addObjectsFromArray:sortedList];
|
|
|
-
|
|
|
- [self.photoListView scrollRectToVisible:CGRectMake(0, 0, 1, 1) animated:YES];
|
|
|
- [self.photoListView reloadData];
|
|
|
- }
|
|
|
- };
|
|
|
+ [[TZImageManager manager] getAssetsFromFetchResult:model.result completion:^(NSArray<TZAssetModel *> *models) {
|
|
|
+ self->_assets = [NSMutableArray arrayWithArray:models];
|
|
|
+ [self.photoListView scrollRectToVisible:CGRectMake(0, 0, 1, 1) animated:YES];
|
|
|
+ [self.photoListView reloadData];
|
|
|
+ }];
|
|
|
|
|
|
- [assetsGroup enumerateAssetsUsingBlock:resultsBlock];
|
|
|
}
|
|
|
|
|
|
#pragma mark - uicollectionDelegate
|