Skip to content

Commit c5e87ef

Browse files
author
yuzheng
committed
加入用NSOperationQueue控制获取原图并发数降低内存的示例;发布3.1.9版本
1 parent 0737c61 commit c5e87ef

14 files changed

Lines changed: 128 additions & 30 deletions

File tree

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,7 @@ A:不要去拿PHImageFileURLKey,没用的,只有通过Photos框架才能
124124

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

127+
3.1.9 加入用NSOperationQueue控制获取原图并发数降低内存的示例
127128
3.1.8 批量获取图片时加入队列控制,尝试优化大批量选择图片时CPU和内存占用过高的问题(仍然危险,maxImagesCount谨慎设置过大...)
128129
3.1.5 相册内无照片时给出提示,修复快速滑动时内存一直增加的问题
129130
3.1.3 适配阿拉伯等语言下从右往左布局的特性

TZImagePickerController.podspec

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
Pod::Spec.new do |s|
22
s.name = "TZImagePickerController"
3-
s.version = "3.1.8"
3+
s.version = "3.1.9"
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.1.8" }
10+
s.source = { :git => "https://github.com/banchichen/TZImagePickerController.git", :tag => "3.1.9" }
1111
s.requires_arc = true
1212
s.resources = "TZImagePickerController/TZImagePickerController/*.{png,bundle}"
1313
s.source_files = "TZImagePickerController/TZImagePickerController/*.{h,m}"

TZImagePickerController.xcodeproj/project.pbxproj

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
900EF00F1C2C0B1100EA709B /* TZAssetModel.m in Sources */ = {isa = PBXBuildFile; fileRef = 900EF00E1C2C0B1100EA709B /* TZAssetModel.m */; };
3030
900EF0121C2C107400EA709B /* TZPhotoPreviewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 900EF0111C2C107400EA709B /* TZPhotoPreviewController.m */; };
3131
900EF0161C2C134900EA709B /* TZPhotoPreviewCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 900EF0141C2C134900EA709B /* TZPhotoPreviewCell.m */; };
32+
9019FD8D21EC25D7009ADEAE /* TZImageUploadOperation.m in Sources */ = {isa = PBXBuildFile; fileRef = 9019FD8C21EC25D7009ADEAE /* TZImageUploadOperation.m */; };
3233
901CC3FA21CB757500C55443 /* TZImageRequestOperation.h in Headers */ = {isa = PBXBuildFile; fileRef = 901CC3F821CB757500C55443 /* TZImageRequestOperation.h */; };
3334
901CC3FB21CB757500C55443 /* TZImageRequestOperation.m in Sources */ = {isa = PBXBuildFile; fileRef = 901CC3F921CB757500C55443 /* TZImageRequestOperation.m */; };
3435
901CC3FC21CB758500C55443 /* TZImageRequestOperation.m in Sources */ = {isa = PBXBuildFile; fileRef = 901CC3F921CB757500C55443 /* TZImageRequestOperation.m */; };
@@ -155,6 +156,8 @@
155156
900EF0111C2C107400EA709B /* TZPhotoPreviewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TZPhotoPreviewController.m; sourceTree = "<group>"; };
156157
900EF0131C2C134800EA709B /* TZPhotoPreviewCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TZPhotoPreviewCell.h; sourceTree = "<group>"; };
157158
900EF0141C2C134900EA709B /* TZPhotoPreviewCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TZPhotoPreviewCell.m; sourceTree = "<group>"; };
159+
9019FD8B21EC25D7009ADEAE /* TZImageUploadOperation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TZImageUploadOperation.h; sourceTree = "<group>"; };
160+
9019FD8C21EC25D7009ADEAE /* TZImageUploadOperation.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TZImageUploadOperation.m; sourceTree = "<group>"; };
158161
901CC3F821CB757500C55443 /* TZImageRequestOperation.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = TZImageRequestOperation.h; sourceTree = "<group>"; };
159162
901CC3F921CB757500C55443 /* TZImageRequestOperation.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = TZImageRequestOperation.m; sourceTree = "<group>"; };
160163
901F2290215CABD600F604ED /* FLAnimatedImage.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FLAnimatedImage.h; sourceTree = "<group>"; };
@@ -254,6 +257,8 @@
254257
900E65831C2BB8D5003D9A9E /* AppDelegate.m */,
255258
900E65851C2BB8D5003D9A9E /* ViewController.h */,
256259
900E65861C2BB8D5003D9A9E /* ViewController.m */,
260+
9019FD8B21EC25D7009ADEAE /* TZImageUploadOperation.h */,
261+
9019FD8C21EC25D7009ADEAE /* TZImageUploadOperation.m */,
257262
6D32B9BB1CD83640005CE1E0 /* LxGridViewFlowLayout.h */,
258263
6D32B9BC1CD83640005CE1E0 /* LxGridViewFlowLayout.m */,
259264
9038D58F1C3974F0007DE549 /* TZTestCell.h */,
@@ -583,6 +588,7 @@
583588
901F2295215CABD600F604ED /* FLAnimatedImage.m in Sources */,
584589
900E65841C2BB8D5003D9A9E /* AppDelegate.m in Sources */,
585590
901F2296215CABD600F604ED /* FLAnimatedImageView.m in Sources */,
591+
9019FD8D21EC25D7009ADEAE /* TZImageUploadOperation.m in Sources */,
586592
900E65811C2BB8D5003D9A9E /* main.m in Sources */,
587593
900EF0121C2C107400EA709B /* TZPhotoPreviewController.m in Sources */,
588594
901CC3FC21CB758500C55443 /* TZImageRequestOperation.m in Sources */,

TZImagePickerController/Info.plist

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
<key>CFBundlePackageType</key>
1616
<string>APPL</string>
1717
<key>CFBundleShortVersionString</key>
18-
<string>3.1.8</string>
18+
<string>3.1.9</string>
1919
<key>CFBundleSignature</key>
2020
<string>????</string>
2121
<key>CFBundleVersion</key>

TZImagePickerController/TZImagePickerController/TZImageManager.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@
7070
/// 如下两个方法completion一般会调多次,一般会先返回缩略图,再返回原图(详见方法内部使用的系统API的说明),如果info[PHImageResultIsDegradedKey] 为 YES,则表明当前返回的是缩略图,否则是原图。
7171
- (PHImageRequestID)getOriginalPhotoWithAsset:(PHAsset *)asset completion:(void (^)(UIImage *photo,NSDictionary *info))completion;
7272
- (PHImageRequestID)getOriginalPhotoWithAsset:(PHAsset *)asset newCompletion:(void (^)(UIImage *photo,NSDictionary *info,BOOL isDegraded))completion;
73+
- (PHImageRequestID)getOriginalPhotoWithAsset:(PHAsset *)asset progressHandler:(void (^)(double progress, NSError *error, BOOL *stop, NSDictionary *info))progressHandler newCompletion:(void (^)(UIImage *photo,NSDictionary *info,BOOL isDegraded))completion;
7374
// 该方法中,completion只会走一次
7475
- (PHImageRequestID)getOriginalPhotoDataWithAsset:(PHAsset *)asset completion:(void (^)(NSData *data,NSDictionary *info,BOOL isDegraded))completion;
7576
- (PHImageRequestID)getOriginalPhotoDataWithAsset:(PHAsset *)asset progressHandler:(void (^)(double progress, NSError *error, BOOL *stop, NSDictionary *info))progressHandler completion:(void (^)(NSData *data,NSDictionary *info,BOOL isDegraded))completion;

TZImagePickerController/TZImagePickerController/TZImageManager.m

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -423,8 +423,15 @@ - (PHImageRequestID)getOriginalPhotoWithAsset:(PHAsset *)asset completion:(void
423423
}
424424

425425
- (PHImageRequestID)getOriginalPhotoWithAsset:(PHAsset *)asset newCompletion:(void (^)(UIImage *photo,NSDictionary *info,BOOL isDegraded))completion {
426+
return [self getOriginalPhotoWithAsset:asset progressHandler:nil newCompletion:completion];
427+
}
428+
429+
- (PHImageRequestID)getOriginalPhotoWithAsset:(PHAsset *)asset progressHandler:(void (^)(double progress, NSError *error, BOOL *stop, NSDictionary *info))progressHandler newCompletion:(void (^)(UIImage *photo,NSDictionary *info,BOOL isDegraded))completion {
426430
PHImageRequestOptions *option = [[PHImageRequestOptions alloc]init];
427431
option.networkAccessAllowed = YES;
432+
if (progressHandler) {
433+
[option setProgressHandler:progressHandler];
434+
}
428435
option.resizeMode = PHImageRequestOptionsResizeModeFast;
429436
return [[PHImageManager defaultManager] requestImageForAsset:asset targetSize:PHImageManagerMaximumSize contentMode:PHImageContentModeAspectFit options:option resultHandler:^(UIImage *result, NSDictionary *info) {
430437
BOOL downloadFinined = (![[info objectForKey:PHImageCancelledKey] boolValue] && ![info objectForKey:PHImageErrorKey]);

TZImagePickerController/TZImagePickerController/TZImagePickerController.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
//
55
// Created by 谭真 on 15/12/24.
66
// Copyright © 2015年 谭真. All rights reserved.
7-
// version 3.1.8 - 2019.01.14
7+
// version 3.1.9 - 2019.01.14
88
// 更多信息,请前往项目的github地址:https://github.com/banchichen/TZImagePickerController
99

1010
/*

TZImagePickerController/TZImagePickerController/TZImagePickerController.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
//
55
// Created by 谭真 on 15/12/24.
66
// Copyright © 2015年 谭真. All rights reserved.
7-
// version 3.1.8 - 2019.01.14
7+
// version 3.1.9 - 2019.01.14
88
// 更多信息,请前往项目的github地址:https://github.com/banchichen/TZImagePickerController
99

1010
#import "TZImagePickerController.h"

TZImagePickerController/TZImagePickerController/TZImageRequestOperation.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,15 @@ NS_ASSUME_NONNULL_BEGIN
1616
typedef void(^TZImageRequestCompletedBlock)(UIImage *photo, NSDictionary *info, BOOL isDegraded);
1717
typedef void(^TZImageRequestProgressBlock)(double progress, NSError *error, BOOL *stop, NSDictionary *info);
1818

19+
@property (nonatomic, copy, nullable) TZImageRequestCompletedBlock completedBlock;
20+
@property (nonatomic, copy, nullable) TZImageRequestProgressBlock progressBlock;
21+
@property (nonatomic, strong, nullable) PHAsset *asset;
22+
23+
@property (assign, nonatomic, getter = isExecuting) BOOL executing;
24+
@property (assign, nonatomic, getter = isFinished) BOOL finished;
25+
1926
- (instancetype)initWithAsset:(PHAsset *)asset completion:(TZImageRequestCompletedBlock)completionBlock progressHandler:(TZImageRequestProgressBlock)progressHandler;
27+
- (void)done;
2028
@end
2129

2230
NS_ASSUME_NONNULL_END

TZImagePickerController/TZImagePickerController/TZImageRequestOperation.m

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,6 @@
99
#import "TZImageRequestOperation.h"
1010
#import "TZImageManager.h"
1111

12-
@interface TZImageRequestOperation ()
13-
@property (nonatomic, copy) TZImageRequestCompletedBlock completedBlock;
14-
@property (nonatomic, copy) TZImageRequestProgressBlock progressBlock;
15-
@property (nonatomic, strong) PHAsset *asset;
16-
17-
@property (assign, nonatomic, getter = isExecuting) BOOL executing;
18-
@property (assign, nonatomic, getter = isFinished) BOOL finished;
19-
@end
20-
2112
@implementation TZImageRequestOperation
2213

2314
@synthesize executing = _executing;

0 commit comments

Comments
 (0)