Skip to content

Commit 49bd669

Browse files
committed
解决提交dark mode合并冲突
2 parents f7c5f13 + 860fba1 commit 49bd669

42 files changed

Lines changed: 346 additions & 64 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
## 重要提示1:提issue前,请先对照Demo、常见问题自查!Demo正常说明你可以升级下新版试试。
1010

11-
## 重要提示2:3.0.7版本适配了iPhoneXR、XS、XS Max,建议大家尽快更新
11+
## 重要提示2:3.4.2版本适配了iOS14,修复2个严重问题,强烈建议尽快更新
1212

1313
关于升级iOS10和Xcdoe8的提示:
1414
在Xcode8环境下将项目运行在iOS10的设备/模拟器中,访问相册和相机需要额外配置info.plist文件。分别是Privacy - Photo Library Usage Description和Privacy - Camera Usage Description字段,详见Demo中info.plist中的设置。
@@ -123,14 +123,15 @@ A:不要去拿PHImageFileURLKey,没用的,只有通过Photos框架才能
123123

124124
## 六. Release Notes 最近更新
125125

126+
**3.4.2 适配iOS14,若干问题修复**
126127
3.3.2 适配iOS13,若干问题修复
127128
3.2.1 新增裁剪用scaleAspectFillCrop属性,设置为YES后,照片尺寸小于裁剪框时会自动放大撑满
128129
3.2.0 加入用NSOperationQueue控制获取原图并发数降低内存的示例
129130
3.1.8 批量获取图片时加入队列控制,尝试优化大批量选择图片时CPU和内存占用过高的问题(仍然危险,maxImagesCount谨慎设置过大...)
130131
3.1.5 相册内无照片时给出提示,修复快速滑动时内存一直增加的问题
131132
3.1.3 适配阿拉伯等语言下从右往左布局的特性
132133
3.0.8 新增gifImagePlayBlock允许使用FLAnimatedImage等替换内部的GIF播放方案
133-
**3.0.7 适配iPhoneXR、XS、XS Max,建议大家尽快更新**
134+
3.0.7 适配iPhoneXR、XS、XS Max
134135
3.0.6 优化保存照片、视频的方法
135136
3.0.1 新增对[TZImagePreviewController](https://github.com/banchichen/TZImagePreviewController)库的支持,允许预览UIImage、NSURL、PHAsset对象
136137
**3.0.0 去除iOS6和7的适配代码,更轻量,最低支持iOS8**

TZImagePickerController.podspec

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
Pod::Spec.new do |s|
22
s.name = "TZImagePickerController"
3-
s.version = "3.3.2"
3+
s.version = "3.4.2"
44
s.summary = "A clone of UIImagePickerController, support picking multiple photos、original photo and video"
55
s.homepage = "https://github.com/banchichen/TZImagePickerController"
66
s.license = "MIT"
77
s.author = { "banchichen" => "tanzhenios@foxmail.com" }
88
s.platform = :ios
99
s.ios.deployment_target = "8.0"
10-
s.source = { :git => "https://github.com/banchichen/TZImagePickerController.git", :tag => "3.3.2" }
10+
s.source = { :git => "https://github.com/banchichen/TZImagePickerController.git", :tag => "3.4.2" }
1111
s.requires_arc = true
1212
s.resources = "TZImagePickerController/TZImagePickerController/*.{png,bundle}"
1313
s.source_files = "TZImagePickerController/TZImagePickerController/*.{h,m}"
14-
s.frameworks = "Photos", "MobileCoreServices"
14+
s.frameworks = "Photos"
1515
end

TZImagePickerController.xcodeproj/project.pbxproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -924,7 +924,7 @@
924924
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
925925
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
926926
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
927-
MARKETING_VERSION = 3.3.2;
927+
MARKETING_VERSION = 3.4.2;
928928
OTHER_LDFLAGS = "-all_load";
929929
PRODUCT_BUNDLE_IDENTIFIER = tanzhen.TZImagePickerControllerFramework;
930930
PRODUCT_NAME = TZImagePickerController;
@@ -965,7 +965,7 @@
965965
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
966966
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
967967
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
968-
MARKETING_VERSION = 3.3.2;
968+
MARKETING_VERSION = 3.4.2;
969969
OTHER_LDFLAGS = "-all_load";
970970
PRODUCT_BUNDLE_IDENTIFIER = tanzhen.TZImagePickerControllerFramework;
971971
PRODUCT_NAME = TZImagePickerController;

TZImagePickerController/TZImagePickerController/TZAssetCell.m

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ - (void)setModel:(TZAssetModel *)model {
4141
// Set the cell's thumbnail image if it's still showing the same asset.
4242
if ([self.representedAssetIdentifier isEqualToString:model.asset.localIdentifier]) {
4343
self.imageView.image = photo;
44+
[self setNeedsLayout];
4445
} else {
4546
// NSLog(@"this cell is showing other asset");
4647
[[PHImageManager defaultManager] cancelImageRequest:self.imageRequestID];
@@ -168,6 +169,12 @@ - (void)requestBigImage {
168169
}
169170

170171
_bigImageRequestID = [[TZImageManager manager] requestImageDataForAsset:_model.asset completion:^(NSData *imageData, NSString *dataUTI, UIImageOrientation orientation, NSDictionary *info) {
172+
BOOL iCloudSyncFailed = !imageData && [TZCommonTools isICloudSyncError:info[PHImageErrorKey]];
173+
self.model.iCloudFailed = iCloudSyncFailed;
174+
if (iCloudSyncFailed && self.didSelectPhotoBlock) {
175+
self.didSelectPhotoBlock(YES);
176+
self.selectImageView.image = self.photoDefImage;
177+
}
171178
[self hideProgressView];
172179
} progressHandler:^(double progress, NSError *error, BOOL *stop, NSDictionary *info) {
173180
if (self.model.isSelected) {
@@ -185,6 +192,18 @@ - (void)requestBigImage {
185192
[self cancelBigImageRequest];
186193
}
187194
}];
195+
if (_model.type == TZAssetCellTypeVideo) {
196+
[[TZImageManager manager] getVideoWithAsset:_model.asset completion:^(AVPlayerItem *playerItem, NSDictionary *info) {
197+
BOOL iCloudSyncFailed = !playerItem && [TZCommonTools isICloudSyncError:info[PHImageErrorKey]];
198+
self.model.iCloudFailed = iCloudSyncFailed;
199+
if (iCloudSyncFailed && self.didSelectPhotoBlock) {
200+
dispatch_async(dispatch_get_main_queue(), ^{
201+
self.didSelectPhotoBlock(YES);
202+
self.selectImageView.image = self.photoDefImage;
203+
});
204+
}
205+
}];
206+
}
188207
}
189208

190209
- (void)cancelBigImageRequest {
@@ -266,6 +285,7 @@ - (UIView *)bottomView {
266285
if (_bottomView == nil) {
267286
UIView *bottomView = [[UIView alloc] init];
268287
static NSInteger rgb = 0;
288+
bottomView.userInteractionEnabled = NO;
269289
bottomView.backgroundColor = [UIColor colorWithRed:rgb green:rgb blue:rgb alpha:0.8];
270290
[self.contentView addSubview:bottomView];
271291
_bottomView = bottomView;
@@ -341,8 +361,8 @@ - (void)layoutSubviews {
341361
_selectImageView.contentMode = UIViewContentModeScaleAspectFit;
342362
}
343363
_indexLabel.frame = _selectImageView.frame;
344-
_imageView.frame = CGRectMake(0, 0, self.tz_width, self.tz_height);
345-
364+
_imageView.frame = self.bounds;
365+
346366
static CGFloat progressWH = 20;
347367
CGFloat progressXY = (self.tz_width - progressWH) / 2;
348368
_progressView.frame = CGRectMake(progressXY, progressXY, progressWH, progressWH);
@@ -398,6 +418,7 @@ - (void)setModel:(TZAlbumModel *)model {
398418
self.titleLabel.attributedText = nameString;
399419
[[TZImageManager manager] getPostImageWithAlbumModel:model completion:^(UIImage *postImage) {
400420
self.posterImageView.image = postImage;
421+
[self setNeedsLayout];
401422
}];
402423
if (model.selectedCount) {
403424
self.selectedCountButton.hidden = NO;

TZImagePickerController/TZImagePickerController/TZAssetModel.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
#import <Foundation/Foundation.h>
1010
#import <UIKit/UIKit.h>
11+
#import <Photos/Photos.h>
1112

1213
typedef enum : NSUInteger {
1314
TZAssetModelMediaTypePhoto = 0,
@@ -24,6 +25,7 @@ typedef enum : NSUInteger {
2425
@property (nonatomic, assign) BOOL isSelected; ///< The select status of a photo, default is No
2526
@property (nonatomic, assign) TZAssetModelMediaType type;
2627
@property (nonatomic, copy) NSString *timeLength;
28+
@property (nonatomic, assign) BOOL iCloudFailed;
2729

2830
/// Init a photo dataModel With a PHAsset
2931
/// 用一个PHAsset实例,初始化一个照片模型
@@ -39,6 +41,8 @@ typedef enum : NSUInteger {
3941
@property (nonatomic, strong) NSString *name; ///< The album name
4042
@property (nonatomic, assign) NSInteger count; ///< Count of photos the album contain
4143
@property (nonatomic, strong) PHFetchResult *result;
44+
@property (nonatomic, strong) PHAssetCollection *collection;
45+
@property (nonatomic, strong) PHFetchOptions *options;
4246

4347
@property (nonatomic, strong) NSArray *models;
4448
@property (nonatomic, strong) NSArray *selectedModels;
@@ -47,5 +51,6 @@ typedef enum : NSUInteger {
4751
@property (nonatomic, assign) BOOL isCameraRoll;
4852

4953
- (void)setResult:(PHFetchResult *)result needFetchAssets:(BOOL)needFetchAssets;
54+
- (void)refreshFetchResult;
5055

5156
@end

TZImagePickerController/TZImagePickerController/TZAssetModel.m

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,12 @@ - (void)setResult:(PHFetchResult *)result needFetchAssets:(BOOL)needFetchAssets
4343
}
4444
}
4545

46+
- (void)refreshFetchResult {
47+
PHFetchResult *fetchResult = [PHAsset fetchAssetsInAssetCollection:self.collection options:self.options];
48+
self.count = fetchResult.count;
49+
[self setResult:fetchResult];
50+
}
51+
4652
- (void)setSelectedModels:(NSArray *)selectedModels {
4753
_selectedModels = selectedModels;
4854
if (_models) {

TZImagePickerController/TZImagePickerController/TZImageManager.m

Lines changed: 23 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ - (void)getCameraRollAlbum:(BOOL)allowPickingVideo allowPickingImage:(BOOL)allow
117117
if (collection.estimatedAssetCount <= 0) continue;
118118
if ([self isCameraRollAlbum:collection]) {
119119
PHFetchResult *fetchResult = [PHAsset fetchAssetsInAssetCollection:collection options:option];
120-
model = [self modelWithResult:fetchResult name:collection.localizedTitle isCameraRoll:YES needFetchAssets:needFetchAssets];
120+
model = [self modelWithResult:fetchResult collection:collection isCameraRoll:YES needFetchAssets:needFetchAssets options:option];
121121
if (completion) completion(model);
122122
break;
123123
}
@@ -159,9 +159,9 @@ - (void)getAllAlbums:(BOOL)allowPickingVideo allowPickingImage:(BOOL)allowPickin
159159
if (collection.assetCollectionSubtype == PHAssetCollectionSubtypeSmartAlbumAllHidden) continue;
160160
if (collection.assetCollectionSubtype == 1000000201) continue; //『最近删除』相册
161161
if ([self isCameraRollAlbum:collection]) {
162-
[albumArr insertObject:[self modelWithResult:fetchResult name:collection.localizedTitle isCameraRoll:YES needFetchAssets:needFetchAssets] atIndex:0];
162+
[albumArr insertObject:[self modelWithResult:fetchResult collection:collection isCameraRoll:YES needFetchAssets:needFetchAssets options:option] atIndex:0];
163163
} else {
164-
[albumArr addObject:[self modelWithResult:fetchResult name:collection.localizedTitle isCameraRoll:NO needFetchAssets:needFetchAssets]];
164+
[albumArr addObject:[self modelWithResult:fetchResult collection:collection isCameraRoll:NO needFetchAssets:needFetchAssets options:option]];
165165
}
166166
}
167167
}
@@ -485,8 +485,7 @@ - (void)savePhotoWithImage:(UIImage *)image location:(CLLocation *)location comp
485485
} completionHandler:^(BOOL success, NSError *error) {
486486
dispatch_async(dispatch_get_main_queue(), ^{
487487
if (success && completion) {
488-
PHAsset *asset = [[PHAsset fetchAssetsWithLocalIdentifiers:@[localIdentifier] options:nil] firstObject];
489-
completion(asset, nil);
488+
[self fetchAssetByIocalIdentifier:localIdentifier retryCount:10 completion:completion];
490489
} else if (error) {
491490
NSLog(@"保存照片出错:%@",error.localizedDescription);
492491
if (completion) {
@@ -522,8 +521,7 @@ - (void)savePhotoWithImage:(UIImage *)image meta:(NSDictionary *)meta location:(
522521
[[NSFileManager defaultManager] removeItemAtPath:path error:nil];
523522
dispatch_async(dispatch_get_main_queue(), ^{
524523
if (success && completion) {
525-
PHAsset *asset = [[PHAsset fetchAssetsWithLocalIdentifiers:@[localIdentifier] options:nil] firstObject];
526-
completion(asset, nil);
524+
[self fetchAssetByIocalIdentifier:localIdentifier retryCount:10 completion:completion];
527525
} else if (error) {
528526
NSLog(@"保存照片出错:%@",error.localizedDescription);
529527
if (completion) {
@@ -534,6 +532,19 @@ - (void)savePhotoWithImage:(UIImage *)image meta:(NSDictionary *)meta location:(
534532
}];
535533
}
536534

535+
- (void)fetchAssetByIocalIdentifier:(NSString *)localIdentifier retryCount:(NSInteger)retryCount completion:(void (^)(PHAsset *asset, NSError *error))completion {
536+
PHAsset *asset = [[PHAsset fetchAssetsWithLocalIdentifiers:@[localIdentifier] options:nil] firstObject];
537+
if (asset || retryCount <= 0) {
538+
if (completion) {
539+
completion(asset, nil);
540+
}
541+
return;
542+
}
543+
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
544+
[self fetchAssetByIocalIdentifier:localIdentifier retryCount:retryCount - 1 completion:completion];
545+
});
546+
}
547+
537548
#pragma mark - Save video
538549

539550
- (void)saveVideoWithUrl:(NSURL *)url completion:(void (^)(PHAsset *asset, NSError *error))completion {
@@ -552,8 +563,7 @@ - (void)saveVideoWithUrl:(NSURL *)url location:(CLLocation *)location completion
552563
} completionHandler:^(BOOL success, NSError *error) {
553564
dispatch_async(dispatch_get_main_queue(), ^{
554565
if (success && completion) {
555-
PHAsset *asset = [[PHAsset fetchAssetsWithLocalIdentifiers:@[localIdentifier] options:nil] firstObject];
556-
completion(asset, nil);
566+
[self fetchAssetByIocalIdentifier:localIdentifier retryCount:10 completion:completion];
557567
} else if (error) {
558568
NSLog(@"保存视频出错:%@",error.localizedDescription);
559569
if (completion) {
@@ -727,10 +737,12 @@ - (BOOL)isPhotoSelectableWithAsset:(PHAsset *)asset {
727737

728738
#pragma mark - Private Method
729739

730-
- (TZAlbumModel *)modelWithResult:(PHFetchResult *)result name:(NSString *)name isCameraRoll:(BOOL)isCameraRoll needFetchAssets:(BOOL)needFetchAssets {
740+
- (TZAlbumModel *)modelWithResult:(PHFetchResult *)result collection:(PHAssetCollection *)collection isCameraRoll:(BOOL)isCameraRoll needFetchAssets:(BOOL)needFetchAssets options:(PHFetchOptions *)options {
731741
TZAlbumModel *model = [[TZAlbumModel alloc] init];
732742
[model setResult:result needFetchAssets:needFetchAssets];
733-
model.name = name;
743+
model.name = collection.localizedTitle;
744+
model.collection = collection;
745+
model.options = options;
734746
model.isCameraRoll = isCameraRoll;
735747
model.count = result.count;
736748
return model;

TZImagePickerController/TZImagePickerController/TZImagePickerController.bundle/ar.lproj/Localizable.strings

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
"Processing..." = "معالجة...";
1313
"No Photos or Videos" = "لا توجد صور أو مقاطع فيديو";
1414
"Synchronizing photos from iCloud" = "مزامنة الصور من iCloud";
15+
"iCloud sync failed" = "iCloud فشلت المزامنة";
1516
"Can not use camera" = "لا يمكن استخدام الكاميرا";
1617
"Can not choose both video and photo" = "لا يمكن اختيار كل من الفيديو والصور";
1718
"Can not choose both photo and GIF" = "لا يمكن اختيار كل من الصور و GIF";

TZImagePickerController/TZImagePickerController/TZImagePickerController.bundle/bg.lproj/Localizable.strings

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
"Processing..." = "Обработка ...";
1313
"No Photos or Videos" = "Няма снимки или видеоклипове";
1414
"Synchronizing photos from iCloud" = "Синхронизиране на снимки от iCloud";
15+
"iCloud sync failed" = "iCloud синхронизирането не бе успешно";
1516
"Can not use camera" = "Не може да се използва камера";
1617
"Can not choose both video and photo" = "Не можете да изберете видео и снимка";
1718
"Can not choose both photo and GIF" = "Не може да се избере снимка и GIF";

TZImagePickerController/TZImagePickerController/TZImagePickerController.bundle/cs-CZ.lproj/Localizable.strings

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
"Processing..." = "Zpracovává se...";
1313
"No Photos or Videos" = "Žádné fotky nebo videa";
1414
"Synchronizing photos from iCloud" = "Synchronizace fotografií z iCloud";
15+
"iCloud sync failed" = "iCloud synchronizace selhala";
1516
"Can not use camera" = "Nelze použít fotoaparát";
1617
"Can not choose both video and photo" = "Nelze vybrat video ani fotografii";
1718
"Can not choose both photo and GIF" = "Nelze vybrat fotografie a GIF";

0 commit comments

Comments
 (0)