|
|
@@ -112,7 +112,23 @@
|
|
|
make.height.mas_equalTo(30);
|
|
|
}];
|
|
|
|
|
|
- [self setTitleLabelText:@"所有相片"];
|
|
|
+ [self setTitleLabelText:@""];
|
|
|
+
|
|
|
+ UIButton *rightBut = [[UIButton alloc] init];
|
|
|
+ [rightBut setTitle:NSLocalizedString(@"File_upload_Record_select_all",nil) forState:UIControlStateNormal];
|
|
|
+ [rightBut setTitle:NSLocalizedString(@"File_upload_cancel_select_all",nil) forState:UIControlStateSelected];
|
|
|
+ [rightBut setTitleColor:[UIColor hwColor:@"#01B7EA" alpha:1.0] forState:UIControlStateNormal];
|
|
|
+ rightBut.contentHorizontalAlignment = UIControlContentHorizontalAlignmentRight;
|
|
|
+ [rightBut addTarget:self action:@selector(didClickSelectAllButton:) forControlEvents:UIControlEventTouchUpInside];
|
|
|
+
|
|
|
+ [self.navBarBGView addSubview:rightBut];
|
|
|
+
|
|
|
+ [rightBut mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
+ make.right.mas_equalTo(-20);
|
|
|
+ make.centerY.mas_equalTo(self.backBtn.mas_centerY);
|
|
|
+ make.width.mas_equalTo(100);
|
|
|
+ make.height.mas_equalTo(30);
|
|
|
+ }];
|
|
|
}
|
|
|
|
|
|
#pragma mark 设置相册标题
|
|
|
@@ -140,6 +156,28 @@
|
|
|
}];
|
|
|
}
|
|
|
|
|
|
+#pragma mark 点击全选
|
|
|
+- (void)didClickSelectAllButton:(UIButton*)but
|
|
|
+{
|
|
|
+ but.selected = !but.selected;
|
|
|
+
|
|
|
+ if(but.selected){
|
|
|
+ [self.indexPathsForSelectedItems removeAllObjects];
|
|
|
+
|
|
|
+ for (TZAssetModel *model in self.assets) {
|
|
|
+ [self didSelectModel:model];
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else{
|
|
|
+ for (TZAssetModel *model in self.assets) {
|
|
|
+ model.isSelected = NO;
|
|
|
+ }
|
|
|
+ [self.indexPathsForSelectedItems removeAllObjects];
|
|
|
+ }
|
|
|
+
|
|
|
+ [self refreshAllDataFun];
|
|
|
+}
|
|
|
+
|
|
|
#pragma mark 判断手机相册权限
|
|
|
- (void)checkVideoAccessFun
|
|
|
{
|
|
|
@@ -399,8 +437,13 @@
|
|
|
- (void)refreshDataAndUIFunWith:(NSMutableArray *)indexPathsForSelectedItems
|
|
|
{
|
|
|
self.indexPathsForSelectedItems = indexPathsForSelectedItems;
|
|
|
+ [self refreshAllDataFun];
|
|
|
+}
|
|
|
+
|
|
|
+#pragma mark 刷新所有数据
|
|
|
+- (void)refreshAllDataFun
|
|
|
+{
|
|
|
[self setDataToBottomViewFun];
|
|
|
-
|
|
|
[self.photoListView reloadData];
|
|
|
}
|
|
|
|
|
|
@@ -422,49 +465,55 @@
|
|
|
model.isSelected = NO;
|
|
|
[cell isSelected:NO];
|
|
|
}
|
|
|
- else{//选中
|
|
|
- [self.indexPathsForSelectedItems addObject:model];
|
|
|
- model.isSelected = YES;
|
|
|
+ else
|
|
|
+ {//选中
|
|
|
+ [self didSelectModel:model];
|
|
|
[cell isSelected:YES];
|
|
|
-
|
|
|
- if(!model.imageData)
|
|
|
- {
|
|
|
- [[PHImageManager defaultManager] requestImageDataForAsset:model.asset options:nil resultHandler:^(NSData * _Nullable imageData, NSString * _Nullable dataUTI, UIImageOrientation orientation, NSDictionary * _Nullable info) {
|
|
|
- // 直接得到最终的 NSData 数据
|
|
|
- if (imageData) {
|
|
|
- model.imageData = imageData;
|
|
|
- }
|
|
|
- if(model.type != TZAssetModelMediaTypeVideo){
|
|
|
- [self setDataToBottomViewFun];
|
|
|
+ }
|
|
|
+
|
|
|
+ [self setDataToBottomViewFun];
|
|
|
+}
|
|
|
+
|
|
|
+#pragma mark 选中某个cell
|
|
|
+- (void)didSelectModel:(TZAssetModel *)model
|
|
|
+{//选中
|
|
|
+ [self.indexPathsForSelectedItems addObject:model];
|
|
|
+ model.isSelected = YES;
|
|
|
+
|
|
|
+ if(!model.imageData)
|
|
|
+ {
|
|
|
+ [[PHImageManager defaultManager] requestImageDataForAsset:model.asset options:nil resultHandler:^(NSData * _Nullable imageData, NSString * _Nullable dataUTI, UIImageOrientation orientation, NSDictionary * _Nullable info) {
|
|
|
+ // 直接得到最终的 NSData 数据
|
|
|
+ if (imageData) {
|
|
|
+ model.imageData = imageData;
|
|
|
}
|
|
|
- }];
|
|
|
+ if(model.type != TZAssetModelMediaTypeVideo){
|
|
|
+ [self setDataToBottomViewFun];
|
|
|
+ }
|
|
|
+ }];
|
|
|
+
|
|
|
+ if(model.type == TZAssetModelMediaTypeVideo){
|
|
|
|
|
|
- if(model.type == TZAssetModelMediaTypeVideo){
|
|
|
-
|
|
|
- PHVideoRequestOptions *options = [[PHVideoRequestOptions alloc] init];
|
|
|
- options.version = PHVideoRequestOptionsVersionOriginal;
|
|
|
- [[PHImageManager defaultManager] requestAVAssetForVideo:model.asset options:options resultHandler:^(AVAsset *asset, AVAudioMix *audioMix, NSDictionary *info) {
|
|
|
- if ([asset isKindOfClass:[AVURLAsset class]]) {
|
|
|
-
|
|
|
- AVURLAsset* urlAsset = (AVURLAsset*)asset;
|
|
|
- NSData *videoData = [NSData dataWithContentsOfURL:urlAsset.URL];
|
|
|
+ PHVideoRequestOptions *options = [[PHVideoRequestOptions alloc] init];
|
|
|
+ options.version = PHVideoRequestOptionsVersionOriginal;
|
|
|
+ [[PHImageManager defaultManager] requestAVAssetForVideo:model.asset options:options resultHandler:^(AVAsset *asset, AVAudioMix *audioMix, NSDictionary *info) {
|
|
|
+ if ([asset isKindOfClass:[AVURLAsset class]]) {
|
|
|
+
|
|
|
+ AVURLAsset* urlAsset = (AVURLAsset*)asset;
|
|
|
+ NSData *videoData = [NSData dataWithContentsOfURL:urlAsset.URL];
|
|
|
// NSNumber *size;
|
|
|
// [urlAsset.URL getResourceValue:&size forKey:NSURLFileSizeKey error:nil];
|
|
|
// NSLog(@"size is %f",[size floatValue]/(1024.0*1024.0));
|
|
|
-
|
|
|
-
|
|
|
- model.videoData = videoData;
|
|
|
- [self setDataToBottomViewFun];
|
|
|
- }
|
|
|
- }];
|
|
|
-
|
|
|
- }
|
|
|
+
|
|
|
+
|
|
|
+ model.videoData = videoData;
|
|
|
+ [self setDataToBottomViewFun];
|
|
|
+ }
|
|
|
+ }];
|
|
|
|
|
|
}
|
|
|
+
|
|
|
}
|
|
|
-
|
|
|
-
|
|
|
- [self setDataToBottomViewFun];
|
|
|
}
|
|
|
|
|
|
#pragma mark 同步数据到底部
|