Commit 0272cd17 authored by banchichen's avatar banchichen

优化拍照照片保存相册的判断,目前已知在8.0-8.0.2版本中,拍照照片会保存在最近添加

parent 1b52982a
...@@ -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>1.6.1</string> <string>1.6.2</string>
<key>CFBundleSignature</key> <key>CFBundleSignature</key>
<string>????</string> <string>????</string>
<key>CFBundleVersion</key> <key>CFBundleVersion</key>
......
...@@ -71,8 +71,12 @@ ...@@ -71,8 +71,12 @@
- (void)setMaxImagesCount:(NSInteger)maxImagesCount { - (void)setMaxImagesCount:(NSInteger)maxImagesCount {
_maxImagesCount = maxImagesCount; _maxImagesCount = maxImagesCount;
if (!self.selectPhotoButton.hidden) {
self.selectPhotoButton.hidden = maxImagesCount == 1; self.selectPhotoButton.hidden = maxImagesCount == 1;
}
if (!self.selectImageView.hidden) {
self.selectImageView.hidden = maxImagesCount == 1; self.selectImageView.hidden = maxImagesCount == 1;
}
} }
- (void)setType:(TZAssetCellType)type { - (void)setType:(TZAssetCellType)type {
......
...@@ -60,5 +60,6 @@ ...@@ -60,5 +60,6 @@
- (BOOL)isAssetsArray:(NSArray *)assets containAsset:(id)asset; - (BOOL)isAssetsArray:(NSArray *)assets containAsset:(id)asset;
- (NSString *)getAssetIdentifier:(id)asset; - (NSString *)getAssetIdentifier:(id)asset;
- (BOOL)isCameraRollAlbum:(NSString *)albumName;
@end @end
...@@ -80,7 +80,7 @@ static CGFloat TZScreenScale; ...@@ -80,7 +80,7 @@ static CGFloat TZScreenScale;
option.sortDescriptors = @[[NSSortDescriptor sortDescriptorWithKey:@"modificationDate" ascending:self.sortAscendingByModificationDate]]; option.sortDescriptors = @[[NSSortDescriptor sortDescriptorWithKey:@"modificationDate" ascending:self.sortAscendingByModificationDate]];
PHFetchResult *smartAlbums = [PHAssetCollection fetchAssetCollectionsWithType:PHAssetCollectionTypeSmartAlbum subtype:PHAssetCollectionSubtypeAlbumRegular options:nil]; PHFetchResult *smartAlbums = [PHAssetCollection fetchAssetCollectionsWithType:PHAssetCollectionTypeSmartAlbum subtype:PHAssetCollectionSubtypeAlbumRegular options:nil];
for (PHAssetCollection *collection in smartAlbums) { for (PHAssetCollection *collection in smartAlbums) {
if ([collection.localizedTitle isEqualToString:@"Camera Roll"] || [collection.localizedTitle isEqualToString:@"相机胶卷"] || [collection.localizedTitle isEqualToString:@"所有照片"] || [collection.localizedTitle isEqualToString:@"All Photos"]) { if ([self isCameraRollAlbum:collection.localizedTitle]) {
PHFetchResult *fetchResult = [PHAsset fetchAssetsInAssetCollection:collection options:option]; PHFetchResult *fetchResult = [PHAsset fetchAssetsInAssetCollection:collection options:option];
model = [self modelWithResult:fetchResult name:collection.localizedTitle]; model = [self modelWithResult:fetchResult name:collection.localizedTitle];
if (completion) completion(model); if (completion) completion(model);
...@@ -94,7 +94,7 @@ static CGFloat TZScreenScale; ...@@ -94,7 +94,7 @@ static CGFloat TZScreenScale;
if ([group numberOfAssets] < 1) return; if ([group numberOfAssets] < 1) return;
NSString *name = [group valueForProperty:ALAssetsGroupPropertyName]; NSString *name = [group valueForProperty:ALAssetsGroupPropertyName];
#pragma clang diagnostic pop #pragma clang diagnostic pop
if ([name isEqualToString:@"Camera Roll"] || [name isEqualToString:@"相机胶卷"] || [name isEqualToString:@"所有照片"] || [name isEqualToString:@"All Photos"]) { if ([self isCameraRollAlbum:name]) {
model = [self modelWithResult:group name:name]; model = [self modelWithResult:group name:name];
if (completion) completion(model); if (completion) completion(model);
*stop = YES; *stop = YES;
...@@ -119,7 +119,7 @@ static CGFloat TZScreenScale; ...@@ -119,7 +119,7 @@ static CGFloat TZScreenScale;
PHFetchResult *fetchResult = [PHAsset fetchAssetsInAssetCollection:collection options:option]; PHFetchResult *fetchResult = [PHAsset fetchAssetsInAssetCollection:collection options:option];
if (fetchResult.count < 1) continue; if (fetchResult.count < 1) continue;
if ([collection.localizedTitle containsString:@"Deleted"] || [collection.localizedTitle isEqualToString:@"最近删除"]) continue; if ([collection.localizedTitle containsString:@"Deleted"] || [collection.localizedTitle isEqualToString:@"最近删除"]) continue;
if ([collection.localizedTitle isEqualToString:@"Camera Roll"] || [collection.localizedTitle isEqualToString:@"相机胶卷"] || [collection.localizedTitle isEqualToString:@"所有照片"] || [collection.localizedTitle isEqualToString:@"All Photos"]) { if ([self isCameraRollAlbum:collection.localizedTitle]) {
[albumArr insertObject:[self modelWithResult:fetchResult name:collection.localizedTitle] atIndex:0]; [albumArr insertObject:[self modelWithResult:fetchResult name:collection.localizedTitle] atIndex:0];
} else { } else {
[albumArr addObject:[self modelWithResult:fetchResult name:collection.localizedTitle]]; [albumArr addObject:[self modelWithResult:fetchResult name:collection.localizedTitle]];
...@@ -144,7 +144,7 @@ static CGFloat TZScreenScale; ...@@ -144,7 +144,7 @@ static CGFloat TZScreenScale;
if ([group numberOfAssets] < 1) return; if ([group numberOfAssets] < 1) return;
NSString *name = [group valueForProperty:ALAssetsGroupPropertyName]; NSString *name = [group valueForProperty:ALAssetsGroupPropertyName];
#pragma clang diagnostic pop #pragma clang diagnostic pop
if ([name isEqualToString:@"Camera Roll"] || [name isEqualToString:@"相机胶卷"] || [name isEqualToString:@"所有照片"] || [name isEqualToString:@"All Photos"]) { if ([self isCameraRollAlbum:name]) {
[albumArr insertObject:[self modelWithResult:group name:name] atIndex:0]; [albumArr insertObject:[self modelWithResult:group name:name] atIndex:0];
} else if ([name isEqualToString:@"My Photo Stream"] || [name isEqualToString:@"我的照片流"]) { } else if ([name isEqualToString:@"My Photo Stream"] || [name isEqualToString:@"我的照片流"]) {
if (albumArr.count) { if (albumArr.count) {
...@@ -668,6 +668,22 @@ static CGFloat TZScreenScale; ...@@ -668,6 +668,22 @@ static CGFloat TZScreenScale;
} }
} }
- (BOOL)isCameraRollAlbum:(NSString *)albumName {
NSString *versionStr = [[UIDevice currentDevice].systemVersion stringByReplacingOccurrencesOfString:@"." withString:@""];
if (versionStr.length <= 1) {
versionStr = [versionStr stringByAppendingString:@"00"];
} else if (versionStr.length <= 2) {
versionStr = [versionStr stringByAppendingString:@"0"];
}
CGFloat version = versionStr.floatValue;
// 目前已知8.0.0 - 8.0.2系统,拍照后的图片会保存在最近添加中
if (version >= 800 && version <= 802) {
return [albumName isEqualToString:@"最近添加"] || [albumName isEqualToString:@"Recently Added"];
} else {
return [albumName isEqualToString:@"Camera Roll"] || [albumName isEqualToString:@"相机胶卷"] || [albumName isEqualToString:@"所有照片"] || [albumName isEqualToString:@"All Photos"];
}
}
- (NSString *)getAssetIdentifier:(id)asset { - (NSString *)getAssetIdentifier:(id)asset {
if (iOS8Later) { if (iOS8Later) {
PHAsset *phAsset = (PHAsset *)asset; PHAsset *phAsset = (PHAsset *)asset;
......
...@@ -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 1.6.1 - 2016.08.19 // version 1.6.2 - 2016.08.23
/* /*
经过测试,比起xib的方式,把TZAssetCell改用纯代码的方式来写,滑动帧数明显提高了(约提高10帧左右) 经过测试,比起xib的方式,把TZAssetCell改用纯代码的方式来写,滑动帧数明显提高了(约提高10帧左右)
......
...@@ -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 1.6.1 - 2016.08.19 // version 1.6.2 - 2016.08.23
#import "TZImagePickerController.h" #import "TZImagePickerController.h"
#import "TZPhotoPickerController.h" #import "TZPhotoPickerController.h"
......
...@@ -70,7 +70,7 @@ static CGSize AssetGridThumbnailSize; ...@@ -70,7 +70,7 @@ static CGSize AssetGridThumbnailSize;
self.view.backgroundColor = [UIColor whiteColor]; self.view.backgroundColor = [UIColor whiteColor];
self.navigationItem.title = _model.name; self.navigationItem.title = _model.name;
self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:[NSBundle tz_localizedStringForKey:@"Cancle"] style:UIBarButtonItemStylePlain target:self action:@selector(cancel)]; self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:[NSBundle tz_localizedStringForKey:@"Cancle"] style:UIBarButtonItemStylePlain target:self action:@selector(cancel)];
_showTakePhotoBtn = (([_model.name isEqualToString:@"相机胶卷"] || [_model.name isEqualToString:@"Camera Roll"] || [_model.name isEqualToString:@"所有照片"] || [_model.name isEqualToString:@"All Photos"]) && tzImagePickerVc.allowTakePicture); _showTakePhotoBtn = (([[TZImageManager manager] isCameraRollAlbum:_model.name]) && tzImagePickerVc.allowTakePicture);
if (!tzImagePickerVc.sortAscendingByModificationDate && _isFirstAppear && iOS8Later) { if (!tzImagePickerVc.sortAscendingByModificationDate && _isFirstAppear && iOS8Later) {
[[TZImageManager manager] getCameraRollAlbum:tzImagePickerVc.allowPickingVideo allowPickingImage:tzImagePickerVc.allowPickingImage completion:^(TZAlbumModel *model) { [[TZImageManager manager] getCameraRollAlbum:tzImagePickerVc.allowPickingVideo allowPickingImage:tzImagePickerVc.allowPickingImage completion:^(TZAlbumModel *model) {
_model = model; _model = model;
......
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