Commit fa4ce1c0 authored by yuzheng's avatar yuzheng

修复快速滑动时内存一直增加的问题;修复快速连续选中iCloud图片时的一处野指针问题;发布3.1.5版本

parent 359303a5
...@@ -124,7 +124,7 @@ A:不要去拿PHImageFileURLKey,没用的,只有通过Photos框架才能 ...@@ -124,7 +124,7 @@ A:不要去拿PHImageFileURLKey,没用的,只有通过Photos框架才能
## 六. Release Notes 最近更新 ## 六. Release Notes 最近更新
3.1.4 相册内无照片时给出提示 3.1.5 相册内无照片时给出提示,修复快速滑动时内存一直增加的问题
3.1.3 适配阿拉伯等语言下从右往左布局的特性 3.1.3 适配阿拉伯等语言下从右往左布局的特性
3.0.8 新增gifImagePlayBlock允许使用FLAnimatedImage等替换内部的GIF播放方案 3.0.8 新增gifImagePlayBlock允许使用FLAnimatedImage等替换内部的GIF播放方案
**3.0.7 适配iPhoneXR、XS、XS Max,建议大家尽快更新** **3.0.7 适配iPhoneXR、XS、XS Max,建议大家尽快更新**
......
Pod::Spec.new do |s| Pod::Spec.new do |s|
s.name = "TZImagePickerController" s.name = "TZImagePickerController"
s.version = "3.1.4" s.version = "3.1.5"
s.summary = "A clone of UIImagePickerController, support picking multiple photos、original photo and video" s.summary = "A clone of UIImagePickerController, support picking multiple photos、original photo and video"
s.homepage = "https://github.com/banchichen/TZImagePickerController" s.homepage = "https://github.com/banchichen/TZImagePickerController"
s.license = "MIT" s.license = "MIT"
s.author = { "banchichen" => "tanzhenios@foxmail.com" } s.author = { "banchichen" => "tanzhenios@foxmail.com" }
s.platform = :ios s.platform = :ios
s.ios.deployment_target = "8.0" s.ios.deployment_target = "8.0"
s.source = { :git => "https://github.com/banchichen/TZImagePickerController.git", :tag => "3.1.4" } s.source = { :git => "https://github.com/banchichen/TZImagePickerController.git", :tag => "3.1.5" }
s.requires_arc = true s.requires_arc = true
s.resources = "TZImagePickerController/TZImagePickerController/*.{png,bundle}" s.resources = "TZImagePickerController/TZImagePickerController/*.{png,bundle}"
s.source_files = "TZImagePickerController/TZImagePickerController/*.{h,m}" s.source_files = "TZImagePickerController/TZImagePickerController/*.{h,m}"
......
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
<key>CFBundlePackageType</key> <key>CFBundlePackageType</key>
<string>APPL</string> <string>APPL</string>
<key>CFBundleShortVersionString</key> <key>CFBundleShortVersionString</key>
<string>3.1.4</string> <string>3.1.5</string>
<key>CFBundleSignature</key> <key>CFBundleSignature</key>
<string>????</string> <string>????</string>
<key>CFBundleVersion</key> <key>CFBundleVersion</key>
......
...@@ -35,7 +35,6 @@ typedef enum : NSUInteger { ...@@ -35,7 +35,6 @@ typedef enum : NSUInteger {
@property (nonatomic, assign) BOOL showSelectBtn; @property (nonatomic, assign) BOOL showSelectBtn;
@property (assign, nonatomic) BOOL allowPreview; @property (assign, nonatomic) BOOL allowPreview;
@property (assign, nonatomic) BOOL useCachedImage;
@property (nonatomic, copy) void (^assetCellDidSetModelBlock)(TZAssetCell *cell, UIImageView *imageView, UIImageView *selectImageView, UILabel *indexLabel, UIView *bottomView, UILabel *timeLength, UIImageView *videoImgView); @property (nonatomic, copy) void (^assetCellDidSetModelBlock)(TZAssetCell *cell, UIImageView *imageView, UIImageView *selectImageView, UILabel *indexLabel, UIView *bottomView, UILabel *timeLength, UIImageView *videoImgView);
@property (nonatomic, copy) void (^assetCellDidLayoutSubviewsBlock)(TZAssetCell *cell, UIImageView *imageView, UIImageView *selectImageView, UILabel *indexLabel, UIView *bottomView, UILabel *timeLength, UIImageView *videoImgView); @property (nonatomic, copy) void (^assetCellDidLayoutSubviewsBlock)(TZAssetCell *cell, UIImageView *imageView, UIImageView *selectImageView, UILabel *indexLabel, UIView *bottomView, UILabel *timeLength, UIImageView *videoImgView);
......
...@@ -28,33 +28,33 @@ ...@@ -28,33 +28,33 @@
@implementation TZAssetCell @implementation TZAssetCell
- (instancetype)initWithFrame:(CGRect)frame {
self = [super initWithFrame:frame];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(reload:) name:@"TZ_PHOTO_PICKER_RELOAD_NOTIFICATION" object:nil];
return self;
}
- (void)setModel:(TZAssetModel *)model { - (void)setModel:(TZAssetModel *)model {
_model = model; _model = model;
self.representedAssetIdentifier = model.asset.localIdentifier; self.representedAssetIdentifier = model.asset.localIdentifier;
if (self.useCachedImage && model.cachedImage) { int32_t imageRequestID = [[TZImageManager manager] getPhotoWithAsset:model.asset photoWidth:self.tz_width completion:^(UIImage *photo, NSDictionary *info, BOOL isDegraded) {
self.imageView.image = model.cachedImage; // Set the cell's thumbnail image if it's still showing the same asset.
} else { if ([self.representedAssetIdentifier isEqualToString:model.asset.localIdentifier]) {
self.model.cachedImage = nil; self.imageView.image = photo;
int32_t imageRequestID = [[TZImageManager manager] getPhotoWithAsset:model.asset photoWidth:self.tz_width completion:^(UIImage *photo, NSDictionary *info, BOOL isDegraded) { } else {
// Set the cell's thumbnail image if it's still showing the same asset. // NSLog(@"this cell is showing other asset");
if ([self.representedAssetIdentifier isEqualToString:model.asset.localIdentifier]) {
self.imageView.image = photo;
self.model.cachedImage = photo;
} else {
// NSLog(@"this cell is showing other asset");
[[PHImageManager defaultManager] cancelImageRequest:self.imageRequestID];
}
if (!isDegraded) {
[self hideProgressView];
self.imageRequestID = 0;
}
} progressHandler:nil networkAccessAllowed:NO];
if (imageRequestID && self.imageRequestID && imageRequestID != self.imageRequestID) {
[[PHImageManager defaultManager] cancelImageRequest:self.imageRequestID]; [[PHImageManager defaultManager] cancelImageRequest:self.imageRequestID];
// NSLog(@"cancelImageRequest %d",self.imageRequestID);
} }
self.imageRequestID = imageRequestID; if (!isDegraded) {
[self hideProgressView];
self.imageRequestID = 0;
}
} progressHandler:nil networkAccessAllowed:NO];
if (imageRequestID && self.imageRequestID && imageRequestID != self.imageRequestID) {
[[PHImageManager defaultManager] cancelImageRequest:self.imageRequestID];
// NSLog(@"cancelImageRequest %d",self.imageRequestID);
} }
self.imageRequestID = imageRequestID;
self.selectPhotoButton.selected = model.isSelected; self.selectPhotoButton.selected = model.isSelected;
self.selectImageView.image = self.selectPhotoButton.isSelected ? self.photoSelImage : self.photoDefImage; self.selectImageView.image = self.selectPhotoButton.isSelected ? self.photoSelImage : self.photoDefImage;
self.indexLabel.hidden = !self.selectPhotoButton.isSelected; self.indexLabel.hidden = !self.selectPhotoButton.isSelected;
...@@ -73,10 +73,6 @@ ...@@ -73,10 +73,6 @@
} else { } else {
[self cancelBigImageRequest]; [self cancelBigImageRequest];
} }
if (model.needOscillatoryAnimation) {
[UIView showOscillatoryAnimationWithLayer:self.selectImageView.layer type:TZOscillatoryAnimationToBigger];
}
model.needOscillatoryAnimation = NO;
[self setNeedsLayout]; [self setNeedsLayout];
if (self.assetCellDidSetModelBlock) { if (self.assetCellDidSetModelBlock) {
...@@ -144,9 +140,7 @@ ...@@ -144,9 +140,7 @@
} }
self.selectImageView.image = sender.isSelected ? self.photoSelImage : self.photoDefImage; self.selectImageView.image = sender.isSelected ? self.photoSelImage : self.photoDefImage;
if (sender.isSelected) { if (sender.isSelected) {
if (![TZImagePickerConfig sharedInstance].showSelectedIndex && ![TZImagePickerConfig sharedInstance].showPhotoCannotSelectLayer) { [UIView showOscillatoryAnimationWithLayer:_selectImageView.layer type:TZOscillatoryAnimationToBigger];
[UIView showOscillatoryAnimationWithLayer:_selectImageView.layer type:TZOscillatoryAnimationToBigger];
}
// 用户选中了该图片,提前获取一下大图 // 用户选中了该图片,提前获取一下大图
[self requestBigImage]; [self requestBigImage];
} else { // 取消选中,取消大图的获取 } else { // 取消选中,取消大图的获取
...@@ -185,7 +179,8 @@ ...@@ -185,7 +179,8 @@
[self hideProgressView]; [self hideProgressView];
} }
} else { } else {
*stop = YES; // 快速连续点几次,会EXC_BAD_ACCESS...
// *stop = YES;
[UIApplication sharedApplication].networkActivityIndicatorVisible = NO; [UIApplication sharedApplication].networkActivityIndicatorVisible = NO;
[self cancelBigImageRequest]; [self cancelBigImageRequest];
} }
...@@ -199,6 +194,22 @@ ...@@ -199,6 +194,22 @@
[self hideProgressView]; [self hideProgressView];
} }
#pragma mark - Notification
- (void)reload:(NSNotification *)noti {
TZImagePickerController *tzImagePickerVc = (TZImagePickerController *)noti.object;
if (self.model.isSelected && tzImagePickerVc.showSelectedIndex) {
self.index = [tzImagePickerVc.selectedAssetIds indexOfObject:self.model.asset.localIdentifier] + 1;
}
self.indexLabel.hidden = !self.selectPhotoButton.isSelected;
if (tzImagePickerVc.selectedModels.count >= tzImagePickerVc.maxImagesCount && tzImagePickerVc.showPhotoCannotSelectLayer && !self.model.isSelected) {
self.cannotSelectLayerButton.backgroundColor = tzImagePickerVc.cannotSelectLayerColor;
self.cannotSelectLayerButton.hidden = NO;
} else {
self.cannotSelectLayerButton.hidden = YES;
}
}
#pragma mark - Lazy load #pragma mark - Lazy load
- (UIButton *)selectPhotoButton { - (UIButton *)selectPhotoButton {
...@@ -338,6 +349,10 @@ ...@@ -338,6 +349,10 @@
} }
} }
- (void)dealloc {
[[NSNotificationCenter defaultCenter] removeObserver:self];
}
@end @end
@interface TZAlbumCell () @interface TZAlbumCell ()
......
...@@ -23,9 +23,7 @@ typedef enum : NSUInteger { ...@@ -23,9 +23,7 @@ typedef enum : NSUInteger {
@property (nonatomic, strong) PHAsset *asset; @property (nonatomic, strong) PHAsset *asset;
@property (nonatomic, assign) BOOL isSelected; ///< The select status of a photo, default is No @property (nonatomic, assign) BOOL isSelected; ///< The select status of a photo, default is No
@property (nonatomic, assign) TZAssetModelMediaType type; @property (nonatomic, assign) TZAssetModelMediaType type;
@property (assign, nonatomic) BOOL needOscillatoryAnimation;
@property (nonatomic, copy) NSString *timeLength; @property (nonatomic, copy) NSString *timeLength;
@property (strong, nonatomic) UIImage *cachedImage;
/// Init a photo dataModel With a PHAsset /// Init a photo dataModel With a PHAsset
/// 用一个PHAsset实例,初始化一个照片模型 /// 用一个PHAsset实例,初始化一个照片模型
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
// //
// Created by 谭真 on 15/12/24. // Created by 谭真 on 15/12/24.
// Copyright © 2015年 谭真. All rights reserved. // Copyright © 2015年 谭真. All rights reserved.
// version 3.1.4 - 2018.11.26 // version 3.1.5 - 2018.11.29
// 更多信息,请前往项目的github地址:https://github.com/banchichen/TZImagePickerController // 更多信息,请前往项目的github地址:https://github.com/banchichen/TZImagePickerController
/* /*
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
// //
// Created by 谭真 on 15/12/24. // Created by 谭真 on 15/12/24.
// Copyright © 2015年 谭真. All rights reserved. // Copyright © 2015年 谭真. All rights reserved.
// version 3.1.4 - 2018.11.26 // version 3.1.5 - 2018.11.29
// 更多信息,请前往项目的github地址:https://github.com/banchichen/TZImagePickerController // 更多信息,请前往项目的github地址:https://github.com/banchichen/TZImagePickerController
#import "TZImagePickerController.h" #import "TZImagePickerController.h"
......
...@@ -42,7 +42,6 @@ ...@@ -42,7 +42,6 @@
@property (strong, nonatomic) UICollectionViewFlowLayout *layout; @property (strong, nonatomic) UICollectionViewFlowLayout *layout;
@property (nonatomic, strong) UIImagePickerController *imagePickerVc; @property (nonatomic, strong) UIImagePickerController *imagePickerVc;
@property (strong, nonatomic) CLLocation *location; @property (strong, nonatomic) CLLocation *location;
@property (assign, nonatomic) BOOL useCachedImage;
@end @end
static CGSize AssetGridThumbnailSize; static CGSize AssetGridThumbnailSize;
...@@ -506,7 +505,6 @@ static CGFloat itemMargin = 5; ...@@ -506,7 +505,6 @@ static CGFloat itemMargin = 5;
cell.allowPickingMultipleVideo = tzImagePickerVc.allowPickingMultipleVideo; cell.allowPickingMultipleVideo = tzImagePickerVc.allowPickingMultipleVideo;
cell.photoDefImage = tzImagePickerVc.photoDefImage; cell.photoDefImage = tzImagePickerVc.photoDefImage;
cell.photoSelImage = tzImagePickerVc.photoSelImage; cell.photoSelImage = tzImagePickerVc.photoSelImage;
cell.useCachedImage = self.useCachedImage;
cell.assetCellDidSetModelBlock = tzImagePickerVc.assetCellDidSetModelBlock; cell.assetCellDidSetModelBlock = tzImagePickerVc.assetCellDidSetModelBlock;
cell.assetCellDidLayoutSubviewsBlock = tzImagePickerVc.assetCellDidLayoutSubviewsBlock; cell.assetCellDidLayoutSubviewsBlock = tzImagePickerVc.assetCellDidLayoutSubviewsBlock;
TZAssetModel *model; TZAssetModel *model;
...@@ -551,7 +549,7 @@ static CGFloat itemMargin = 5; ...@@ -551,7 +549,7 @@ static CGFloat itemMargin = 5;
} }
[strongSelf refreshBottomToolBarStatus]; [strongSelf refreshBottomToolBarStatus];
if (tzImagePickerVc.showSelectedIndex || tzImagePickerVc.showPhotoCannotSelectLayer) { if (tzImagePickerVc.showSelectedIndex || tzImagePickerVc.showPhotoCannotSelectLayer) {
[strongSelf setUseCachedImageAndReloadData]; [[NSNotificationCenter defaultCenter] postNotificationName:@"TZ_PHOTO_PICKER_RELOAD_NOTIFICATION" object:strongSelf.navigationController];
} }
[UIView showOscillatoryAnimationWithLayer:strongLayer type:TZOscillatoryAnimationToSmaller]; [UIView showOscillatoryAnimationWithLayer:strongLayer type:TZOscillatoryAnimationToSmaller];
} else { } else {
...@@ -565,11 +563,10 @@ static CGFloat itemMargin = 5; ...@@ -565,11 +563,10 @@ static CGFloat itemMargin = 5;
} }
strongCell.selectPhotoButton.selected = YES; strongCell.selectPhotoButton.selected = YES;
model.isSelected = YES; model.isSelected = YES;
[tzImagePickerVc addSelectedModel:model];
if (tzImagePickerVc.showSelectedIndex || tzImagePickerVc.showPhotoCannotSelectLayer) { if (tzImagePickerVc.showSelectedIndex || tzImagePickerVc.showPhotoCannotSelectLayer) {
model.needOscillatoryAnimation = YES; [[NSNotificationCenter defaultCenter] postNotificationName:@"TZ_PHOTO_PICKER_RELOAD_NOTIFICATION" object:strongSelf.navigationController];
[strongSelf setUseCachedImageAndReloadData];
} }
[tzImagePickerVc addSelectedModel:model];
[strongSelf refreshBottomToolBarStatus]; [strongSelf refreshBottomToolBarStatus];
[UIView showOscillatoryAnimationWithLayer:strongLayer type:TZOscillatoryAnimationToSmaller]; [UIView showOscillatoryAnimationWithLayer:strongLayer type:TZOscillatoryAnimationToSmaller];
} else { } else {
...@@ -627,14 +624,6 @@ static CGFloat itemMargin = 5; ...@@ -627,14 +624,6 @@ static CGFloat itemMargin = 5;
#pragma mark - Private Method #pragma mark - Private Method
- (void)setUseCachedImageAndReloadData {
self.useCachedImage = YES;
[self.collectionView reloadData];
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
self.useCachedImage = NO;
});
}
/// 拍照按钮点击事件 /// 拍照按钮点击事件
- (void)takePhoto { - (void)takePhoto {
AVAuthorizationStatus authStatus = [AVCaptureDevice authorizationStatusForMediaType:AVMediaTypeVideo]; AVAuthorizationStatus authStatus = [AVCaptureDevice authorizationStatusForMediaType:AVMediaTypeVideo];
......
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
<key>CFBundlePackageType</key> <key>CFBundlePackageType</key>
<string>FMWK</string> <string>FMWK</string>
<key>CFBundleShortVersionString</key> <key>CFBundleShortVersionString</key>
<string>3.1.4</string> <string>3.1.5</string>
<key>CFBundleVersion</key> <key>CFBundleVersion</key>
<string>$(CURRENT_PROJECT_VERSION)</string> <string>$(CURRENT_PROJECT_VERSION)</string>
<key>NSPrincipalClass</key> <key>NSPrincipalClass</key>
......
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