Commit c49d55cf authored by Zhen Tan's avatar Zhen Tan Committed by GitHub

Merge pull request #164 from bringbird/master

消除因适配不同系统版本调用过期API的警告
parents 0ad0c02f 0de5bea9
...@@ -12,7 +12,10 @@ ...@@ -12,7 +12,10 @@
#import "TZImagePickerController.h" #import "TZImagePickerController.h"
@interface TZImageManager () @interface TZImageManager ()
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
@property (nonatomic, strong) ALAssetsLibrary *assetLibrary; @property (nonatomic, strong) ALAssetsLibrary *assetLibrary;
#pragma clang diagnostic pop
@end @end
@implementation TZImageManager @implementation TZImageManager
...@@ -42,8 +45,11 @@ static CGFloat TZScreenScale; ...@@ -42,8 +45,11 @@ static CGFloat TZScreenScale;
return manager; return manager;
} }
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
- (ALAssetsLibrary *)assetLibrary { - (ALAssetsLibrary *)assetLibrary {
if (_assetLibrary == nil) _assetLibrary = [[ALAssetsLibrary alloc] init]; if (_assetLibrary == nil) _assetLibrary = [[ALAssetsLibrary alloc] init];
#pragma clang diagnostic pop
return _assetLibrary; return _assetLibrary;
} }
...@@ -52,7 +58,10 @@ static CGFloat TZScreenScale; ...@@ -52,7 +58,10 @@ static CGFloat TZScreenScale;
if (iOS8Later) { if (iOS8Later) {
if ([PHPhotoLibrary authorizationStatus] == PHAuthorizationStatusAuthorized) return YES; if ([PHPhotoLibrary authorizationStatus] == PHAuthorizationStatusAuthorized) return YES;
} else { } else {
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
if ([ALAssetsLibrary authorizationStatus] == ALAuthorizationStatusAuthorized) return YES; if ([ALAssetsLibrary authorizationStatus] == ALAuthorizationStatusAuthorized) return YES;
#pragma clang diagnostic pop
} }
return NO; return NO;
} }
...@@ -80,9 +89,13 @@ static CGFloat TZScreenScale; ...@@ -80,9 +89,13 @@ static CGFloat TZScreenScale;
} }
} }
} else { } else {
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
[self.assetLibrary enumerateGroupsWithTypes:ALAssetsGroupAll usingBlock:^(ALAssetsGroup *group, BOOL *stop) { [self.assetLibrary enumerateGroupsWithTypes:ALAssetsGroupAll usingBlock:^(ALAssetsGroup *group, BOOL *stop) {
if ([group numberOfAssets] < 1) return; if ([group numberOfAssets] < 1) return;
NSString *name = [group valueForProperty:ALAssetsGroupPropertyName]; NSString *name = [group valueForProperty:ALAssetsGroupPropertyName];
#pragma clang diagnostic pop
if ([name isEqualToString:@"Camera Roll"] || [name isEqualToString:@"相机胶卷"] || [name isEqualToString:@"所有照片"] || [name isEqualToString:@"All Photos"]) { if ([name isEqualToString:@"Camera Roll"] || [name isEqualToString:@"相机胶卷"] || [name isEqualToString:@"所有照片"] || [name isEqualToString:@"All Photos"]) {
model = [self modelWithResult:group name:name]; model = [self modelWithResult:group name:name];
if (completion) completion(model); if (completion) completion(model);
...@@ -136,12 +149,18 @@ static CGFloat TZScreenScale; ...@@ -136,12 +149,18 @@ static CGFloat TZScreenScale;
} }
if (completion && albumArr.count > 0) completion(albumArr); if (completion && albumArr.count > 0) completion(albumArr);
} else { } else {
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
[self.assetLibrary enumerateGroupsWithTypes:ALAssetsGroupAll usingBlock:^(ALAssetsGroup *group, BOOL *stop) { [self.assetLibrary enumerateGroupsWithTypes:ALAssetsGroupAll usingBlock:^(ALAssetsGroup *group, BOOL *stop) {
#pragma clang diagnostic pop
if (group == nil) { if (group == nil) {
if (completion && albumArr.count > 0) completion(albumArr); if (completion && albumArr.count > 0) completion(albumArr);
} }
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
if ([group numberOfAssets] < 1) return; if ([group numberOfAssets] < 1) return;
NSString *name = [group valueForProperty:ALAssetsGroupPropertyName]; NSString *name = [group valueForProperty:ALAssetsGroupPropertyName];
#pragma clang diagnostic pop
if ([name isEqualToString:@"Camera Roll"] || [name isEqualToString:@"相机胶卷"] || [name isEqualToString:@"所有照片"] || [name isEqualToString:@"All Photos"]) { if ([name isEqualToString:@"Camera Roll"] || [name isEqualToString:@"相机胶卷"] || [name isEqualToString:@"所有照片"] || [name isEqualToString:@"All Photos"]) {
[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:@"我的照片流"]) {
...@@ -182,6 +201,8 @@ static CGFloat TZScreenScale; ...@@ -182,6 +201,8 @@ static CGFloat TZScreenScale;
[photoArr addObject:[TZAssetModel modelWithAsset:asset type:type timeLength:timeLength]]; [photoArr addObject:[TZAssetModel modelWithAsset:asset type:type timeLength:timeLength]];
}]; }];
if (completion) completion(photoArr); if (completion) completion(photoArr);
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
} else if ([result isKindOfClass:[ALAssetsGroup class]]) { } else if ([result isKindOfClass:[ALAssetsGroup class]]) {
ALAssetsGroup *group = (ALAssetsGroup *)result; ALAssetsGroup *group = (ALAssetsGroup *)result;
if (allowPickingImage && allowPickingVideo) { if (allowPickingImage && allowPickingVideo) {
...@@ -192,6 +213,7 @@ static CGFloat TZScreenScale; ...@@ -192,6 +213,7 @@ static CGFloat TZScreenScale;
[group setAssetsFilter:[ALAssetsFilter allPhotos]]; [group setAssetsFilter:[ALAssetsFilter allPhotos]];
} }
ALAssetsGroupEnumerationResultsBlock resultBlock = ^(ALAsset *result, NSUInteger index, BOOL *stop) { ALAssetsGroupEnumerationResultsBlock resultBlock = ^(ALAsset *result, NSUInteger index, BOOL *stop) {
#pragma clang diagnostic pop
if (result == nil) { if (result == nil) {
if (completion) completion(photoArr); if (completion) completion(photoArr);
} }
...@@ -201,9 +223,12 @@ static CGFloat TZScreenScale; ...@@ -201,9 +223,12 @@ static CGFloat TZScreenScale;
return; return;
} }
/// Allow picking video /// Allow picking video
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
if ([[result valueForProperty:ALAssetPropertyType] isEqualToString:ALAssetTypeVideo]) { if ([[result valueForProperty:ALAssetPropertyType] isEqualToString:ALAssetTypeVideo]) {
type = TZAssetModelMediaTypeVideo; type = TZAssetModelMediaTypeVideo;
NSTimeInterval duration = [[result valueForProperty:ALAssetPropertyDuration] integerValue]; NSTimeInterval duration = [[result valueForProperty:ALAssetPropertyDuration] integerValue];
#pragma clang diagnostic pop
NSString *timeLength = [NSString stringWithFormat:@"%0.0f",duration]; NSString *timeLength = [NSString stringWithFormat:@"%0.0f",duration];
timeLength = [self getNewTimeFromDurationSecond:timeLength.integerValue]; timeLength = [self getNewTimeFromDurationSecond:timeLength.integerValue];
[photoArr addObject:[TZAssetModel modelWithAsset:result type:type timeLength:timeLength]]; [photoArr addObject:[TZAssetModel modelWithAsset:result type:type timeLength:timeLength]];
...@@ -211,12 +236,18 @@ static CGFloat TZScreenScale; ...@@ -211,12 +236,18 @@ static CGFloat TZScreenScale;
[photoArr addObject:[TZAssetModel modelWithAsset:result type:type]]; [photoArr addObject:[TZAssetModel modelWithAsset:result type:type]];
} }
}; };
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
if (self.sortAscendingByModificationDate) { if (self.sortAscendingByModificationDate) {
[group enumerateAssetsUsingBlock:^(ALAsset *result, NSUInteger index, BOOL *stop) { [group enumerateAssetsUsingBlock:^(ALAsset *result, NSUInteger index, BOOL *stop) {
if (resultBlock) { resultBlock(result,index,stop); } if (resultBlock) { resultBlock(result,index,stop); }
#pragma clang diagnostic pop
}]; }];
} else { } else {
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
[group enumerateAssetsWithOptions:NSEnumerationReverse usingBlock:^(ALAsset *result, NSUInteger index, BOOL *stop) { [group enumerateAssetsWithOptions:NSEnumerationReverse usingBlock:^(ALAsset *result, NSUInteger index, BOOL *stop) {
#pragma clang diagnostic pop
if (resultBlock) { resultBlock(result,index,stop); } if (resultBlock) { resultBlock(result,index,stop); }
}]; }];
} }
...@@ -249,6 +280,8 @@ static CGFloat TZScreenScale; ...@@ -249,6 +280,8 @@ static CGFloat TZScreenScale;
timeLength = [self getNewTimeFromDurationSecond:timeLength.integerValue]; timeLength = [self getNewTimeFromDurationSecond:timeLength.integerValue];
TZAssetModel *model = [TZAssetModel modelWithAsset:asset type:type timeLength:timeLength]; TZAssetModel *model = [TZAssetModel modelWithAsset:asset type:type timeLength:timeLength];
if (completion) completion(model); if (completion) completion(model);
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
} else if ([result isKindOfClass:[ALAssetsGroup class]]) { } else if ([result isKindOfClass:[ALAssetsGroup class]]) {
ALAssetsGroup *group = (ALAssetsGroup *)result; ALAssetsGroup *group = (ALAssetsGroup *)result;
if (allowPickingImage && allowPickingVideo) { if (allowPickingImage && allowPickingVideo) {
...@@ -258,10 +291,14 @@ static CGFloat TZScreenScale; ...@@ -258,10 +291,14 @@ static CGFloat TZScreenScale;
} else if (allowPickingImage) { } else if (allowPickingImage) {
[group setAssetsFilter:[ALAssetsFilter allPhotos]]; [group setAssetsFilter:[ALAssetsFilter allPhotos]];
} }
#pragma clang diagnostic pop
NSIndexSet *indexSet = [NSIndexSet indexSetWithIndex:index]; NSIndexSet *indexSet = [NSIndexSet indexSetWithIndex:index];
@try { @try {
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
[group enumerateAssetsAtIndexes:indexSet options:NSEnumerationConcurrent usingBlock:^(ALAsset *result, NSUInteger index, BOOL *stop) { [group enumerateAssetsAtIndexes:indexSet options:NSEnumerationConcurrent usingBlock:^(ALAsset *result, NSUInteger index, BOOL *stop) {
#pragma clang diagnostic pop
if (!result) return; if (!result) return;
...@@ -273,9 +310,12 @@ static CGFloat TZScreenScale; ...@@ -273,9 +310,12 @@ static CGFloat TZScreenScale;
return; return;
} }
/// Allow picking video /// Allow picking video
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
if ([[result valueForProperty:ALAssetPropertyType] isEqualToString:ALAssetTypeVideo]) { if ([[result valueForProperty:ALAssetPropertyType] isEqualToString:ALAssetTypeVideo]) {
type = TZAssetModelMediaTypeVideo; type = TZAssetModelMediaTypeVideo;
NSTimeInterval duration = [[result valueForProperty:ALAssetPropertyDuration] integerValue]; NSTimeInterval duration = [[result valueForProperty:ALAssetPropertyDuration] integerValue];
#pragma clang diagnostic pop
NSString *timeLength = [NSString stringWithFormat:@"%0.0f",duration]; NSString *timeLength = [NSString stringWithFormat:@"%0.0f",duration];
timeLength = [self getNewTimeFromDurationSecond:timeLength.integerValue]; timeLength = [self getNewTimeFromDurationSecond:timeLength.integerValue];
model = [TZAssetModel modelWithAsset:result type:type timeLength:timeLength]; model = [TZAssetModel modelWithAsset:result type:type timeLength:timeLength];
...@@ -325,9 +365,12 @@ static CGFloat TZScreenScale; ...@@ -325,9 +365,12 @@ static CGFloat TZScreenScale;
if (completion) completion(bytes); if (completion) completion(bytes);
} }
}]; }];
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
} else if ([model.asset isKindOfClass:[ALAsset class]]) { } else if ([model.asset isKindOfClass:[ALAsset class]]) {
ALAssetRepresentation *representation = [model.asset defaultRepresentation]; ALAssetRepresentation *representation = [model.asset defaultRepresentation];
if (model.type != TZAssetModelMediaTypeVideo) dataLength += (NSInteger)representation.size; if (model.type != TZAssetModelMediaTypeVideo) dataLength += (NSInteger)representation.size;
#pragma clang diagnostic pop
if (i >= photos.count - 1) { if (i >= photos.count - 1) {
NSString *bytes = [self getBytesFromDataLength:dataLength]; NSString *bytes = [self getBytesFromDataLength:dataLength];
if (completion) completion(bytes); if (completion) completion(bytes);
...@@ -397,18 +440,24 @@ static CGFloat TZScreenScale; ...@@ -397,18 +440,24 @@ static CGFloat TZScreenScale;
} }
}]; }];
return imageRequestID; return imageRequestID;
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
} else if ([asset isKindOfClass:[ALAsset class]]) { } else if ([asset isKindOfClass:[ALAsset class]]) {
ALAsset *alAsset = (ALAsset *)asset; ALAsset *alAsset = (ALAsset *)asset;
dispatch_async(dispatch_get_global_queue(0,0), ^{ dispatch_async(dispatch_get_global_queue(0,0), ^{
CGImageRef thumbnailImageRef = alAsset.thumbnail; CGImageRef thumbnailImageRef = alAsset.thumbnail;
UIImage *thumbnailImage = [UIImage imageWithCGImage:thumbnailImageRef scale:2.0 orientation:UIImageOrientationUp]; UIImage *thumbnailImage = [UIImage imageWithCGImage:thumbnailImageRef scale:2.0 orientation:UIImageOrientationUp];
#pragma clang diagnostic pop
dispatch_async(dispatch_get_main_queue(), ^{ dispatch_async(dispatch_get_main_queue(), ^{
if (completion) completion(thumbnailImage,nil,YES); if (completion) completion(thumbnailImage,nil,YES);
if (photoWidth == TZScreenWidth || photoWidth == _photoPreviewMaxWidth) { if (photoWidth == TZScreenWidth || photoWidth == _photoPreviewMaxWidth) {
dispatch_async(dispatch_get_global_queue(0,0), ^{ dispatch_async(dispatch_get_global_queue(0,0), ^{
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
ALAssetRepresentation *assetRep = [alAsset defaultRepresentation]; ALAssetRepresentation *assetRep = [alAsset defaultRepresentation];
CGImageRef fullScrennImageRef = [assetRep fullScreenImage]; CGImageRef fullScrennImageRef = [assetRep fullScreenImage];
#pragma clang diagnostic pop
UIImage *fullScrennImage = [UIImage imageWithCGImage:fullScrennImageRef scale:2.0 orientation:UIImageOrientationUp]; UIImage *fullScrennImage = [UIImage imageWithCGImage:fullScrennImageRef scale:2.0 orientation:UIImageOrientationUp];
dispatch_async(dispatch_get_main_queue(), ^{ dispatch_async(dispatch_get_main_queue(), ^{
...@@ -433,8 +482,11 @@ static CGFloat TZScreenScale; ...@@ -433,8 +482,11 @@ static CGFloat TZScreenScale;
if (completion) completion(photo); if (completion) completion(photo);
}]; }];
} else { } else {
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
ALAssetsGroup *group = model.result; ALAssetsGroup *group = model.result;
UIImage *postImage = [UIImage imageWithCGImage:group.posterImage]; UIImage *postImage = [UIImage imageWithCGImage:group.posterImage];
#pragma clang diagnostic pop
if (completion) completion(postImage); if (completion) completion(postImage);
} }
} }
...@@ -451,12 +503,18 @@ static CGFloat TZScreenScale; ...@@ -451,12 +503,18 @@ static CGFloat TZScreenScale;
if (completion) completion(result,info); if (completion) completion(result,info);
} }
}]; }];
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
} else if ([asset isKindOfClass:[ALAsset class]]) { } else if ([asset isKindOfClass:[ALAsset class]]) {
ALAsset *alAsset = (ALAsset *)asset; ALAsset *alAsset = (ALAsset *)asset;
ALAssetRepresentation *assetRep = [alAsset defaultRepresentation]; ALAssetRepresentation *assetRep = [alAsset defaultRepresentation];
#pragma clang diagnostic pop
dispatch_async(dispatch_get_global_queue(0,0), ^{ dispatch_async(dispatch_get_global_queue(0,0), ^{
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
CGImageRef originalImageRef = [assetRep fullResolutionImage]; CGImageRef originalImageRef = [assetRep fullResolutionImage];
#pragma clang diagnostic pop
UIImage *originalImage = [UIImage imageWithCGImage:originalImageRef scale:1.0 orientation:UIImageOrientationUp]; UIImage *originalImage = [UIImage imageWithCGImage:originalImageRef scale:1.0 orientation:UIImageOrientationUp];
dispatch_async(dispatch_get_main_queue(), ^{ dispatch_async(dispatch_get_main_queue(), ^{
...@@ -485,7 +543,10 @@ static CGFloat TZScreenScale; ...@@ -485,7 +543,10 @@ static CGFloat TZScreenScale;
}); });
}]; }];
} else { } else {
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
[self.assetLibrary writeImageToSavedPhotosAlbum:image.CGImage orientation:[self orientationFromImage:image] completionBlock:^(NSURL *assetURL, NSError *error) { [self.assetLibrary writeImageToSavedPhotosAlbum:image.CGImage orientation:[self orientationFromImage:image] completionBlock:^(NSURL *assetURL, NSError *error) {
#pragma clang diagnostic pop
if (error) { if (error) {
NSLog(@"保存图片失败:%@",error.localizedDescription); NSLog(@"保存图片失败:%@",error.localizedDescription);
} else { } else {
...@@ -505,11 +566,14 @@ static CGFloat TZScreenScale; ...@@ -505,11 +566,14 @@ static CGFloat TZScreenScale;
[[PHImageManager defaultManager] requestPlayerItemForVideo:asset options:nil resultHandler:^(AVPlayerItem * _Nullable playerItem, NSDictionary * _Nullable info) { [[PHImageManager defaultManager] requestPlayerItemForVideo:asset options:nil resultHandler:^(AVPlayerItem * _Nullable playerItem, NSDictionary * _Nullable info) {
if (completion) completion(playerItem,info); if (completion) completion(playerItem,info);
}]; }];
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
} else if ([asset isKindOfClass:[ALAsset class]]) { } else if ([asset isKindOfClass:[ALAsset class]]) {
ALAsset *alAsset = (ALAsset *)asset; ALAsset *alAsset = (ALAsset *)asset;
ALAssetRepresentation *defaultRepresentation = [alAsset defaultRepresentation]; ALAssetRepresentation *defaultRepresentation = [alAsset defaultRepresentation];
NSString *uti = [defaultRepresentation UTI]; NSString *uti = [defaultRepresentation UTI];
NSURL *videoURL = [[asset valueForProperty:ALAssetPropertyURLs] valueForKey:uti]; NSURL *videoURL = [[asset valueForProperty:ALAssetPropertyURLs] valueForKey:uti];
#pragma clang diagnostic pop
AVPlayerItem *playerItem = [[AVPlayerItem alloc] initWithURL:videoURL]; AVPlayerItem *playerItem = [[AVPlayerItem alloc] initWithURL:videoURL];
if (completion && playerItem) completion(playerItem,nil); if (completion && playerItem) completion(playerItem,nil);
} }
...@@ -530,8 +594,11 @@ static CGFloat TZScreenScale; ...@@ -530,8 +594,11 @@ static CGFloat TZScreenScale;
// NSLog(@"AVAsset URL: %@",myAsset.URL); // NSLog(@"AVAsset URL: %@",myAsset.URL);
[self startExportVideoWithVideoAsset:videoAsset completion:completion]; [self startExportVideoWithVideoAsset:videoAsset completion:completion];
}]; }];
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
} else if ([asset isKindOfClass:[ALAsset class]]) { } else if ([asset isKindOfClass:[ALAsset class]]) {
NSURL *videoURL =[asset valueForProperty:ALAssetPropertyAssetURL]; // ALAssetPropertyURLs NSURL *videoURL =[asset valueForProperty:ALAssetPropertyAssetURL]; // ALAssetPropertyURLs
#pragma clang diagnostic pop
AVURLAsset *videoAsset = [[AVURLAsset alloc]initWithURL:videoURL options:nil]; AVURLAsset *videoAsset = [[AVURLAsset alloc]initWithURL:videoURL options:nil];
[self startExportVideoWithVideoAsset:videoAsset completion:completion]; [self startExportVideoWithVideoAsset:videoAsset completion:completion];
} }
...@@ -602,10 +669,13 @@ static CGFloat TZScreenScale; ...@@ -602,10 +669,13 @@ static CGFloat TZScreenScale;
return [assets containsObject:asset]; return [assets containsObject:asset];
} else { } else {
NSMutableArray *selectedAssetUrls = [NSMutableArray array]; NSMutableArray *selectedAssetUrls = [NSMutableArray array];
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
for (ALAsset *asset_item in assets) { for (ALAsset *asset_item in assets) {
[selectedAssetUrls addObject:[asset_item valueForProperty:ALAssetPropertyURLs]]; [selectedAssetUrls addObject:[asset_item valueForProperty:ALAssetPropertyURLs]];
} }
return [selectedAssetUrls containsObject:[asset valueForProperty:ALAssetPropertyURLs]]; return [selectedAssetUrls containsObject:[asset valueForProperty:ALAssetPropertyURLs]];
#pragma clang diagnostic pop
} }
} }
...@@ -614,8 +684,11 @@ static CGFloat TZScreenScale; ...@@ -614,8 +684,11 @@ static CGFloat TZScreenScale;
PHAsset *phAsset = (PHAsset *)asset; PHAsset *phAsset = (PHAsset *)asset;
return phAsset.localIdentifier; return phAsset.localIdentifier;
} else { } else {
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
ALAsset *alAsset = (ALAsset *)asset; ALAsset *alAsset = (ALAsset *)asset;
NSURL *assetUrl = [alAsset valueForProperty:ALAssetPropertyAssetURL]; NSURL *assetUrl = [alAsset valueForProperty:ALAssetPropertyAssetURL];
#pragma clang diagnostic pop
return assetUrl.absoluteString; return assetUrl.absoluteString;
} }
} }
...@@ -629,9 +702,12 @@ static CGFloat TZScreenScale; ...@@ -629,9 +702,12 @@ static CGFloat TZScreenScale;
if ([result isKindOfClass:[PHFetchResult class]]) { if ([result isKindOfClass:[PHFetchResult class]]) {
PHFetchResult *fetchResult = (PHFetchResult *)result; PHFetchResult *fetchResult = (PHFetchResult *)result;
model.count = fetchResult.count; model.count = fetchResult.count;
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
} else if ([result isKindOfClass:[ALAssetsGroup class]]) { } else if ([result isKindOfClass:[ALAssetsGroup class]]) {
ALAssetsGroup *group = (ALAssetsGroup *)result; ALAssetsGroup *group = (ALAssetsGroup *)result;
model.count = [group numberOfAssets]; model.count = [group numberOfAssets];
#pragma clang diagnostic pop
} }
return model; return model;
} }
...@@ -665,8 +741,10 @@ static CGFloat TZScreenScale; ...@@ -665,8 +741,10 @@ static CGFloat TZScreenScale;
return image; return image;
} }
} }
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
- (ALAssetOrientation)orientationFromImage:(UIImage *)image { - (ALAssetOrientation)orientationFromImage:(UIImage *)image {
#pragma clang diagnostic pop
NSInteger orientation = image.imageOrientation; NSInteger orientation = image.imageOrientation;
return orientation; return orientation;
} }
......
...@@ -52,7 +52,10 @@ ...@@ -52,7 +52,10 @@
if (iOS9Later) { if (iOS9Later) {
barItem = [UIBarButtonItem appearanceWhenContainedInInstancesOfClasses:@[[TZImagePickerController class]]]; barItem = [UIBarButtonItem appearanceWhenContainedInInstancesOfClasses:@[[TZImagePickerController class]]];
} else { } else {
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
barItem = [UIBarButtonItem appearanceWhenContainedIn:[TZImagePickerController class], nil]; barItem = [UIBarButtonItem appearanceWhenContainedIn:[TZImagePickerController class], nil];
#pragma clang diagnostic pop
} }
NSMutableDictionary *textAttrs = [NSMutableDictionary dictionary]; NSMutableDictionary *textAttrs = [NSMutableDictionary dictionary];
textAttrs[NSForegroundColorAttributeName] = [UIColor whiteColor]; textAttrs[NSForegroundColorAttributeName] = [UIColor whiteColor];
...@@ -63,7 +66,10 @@ ...@@ -63,7 +66,10 @@
- (void)viewWillAppear:(BOOL)animated { - (void)viewWillAppear:(BOOL)animated {
[super viewWillAppear:animated]; [super viewWillAppear:animated];
_originStatusBarStyle = [UIApplication sharedApplication].statusBarStyle; _originStatusBarStyle = [UIApplication sharedApplication].statusBarStyle;
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
[UIApplication sharedApplication].statusBarStyle = iOS7Later ? UIStatusBarStyleLightContent : UIStatusBarStyleBlackOpaque; [UIApplication sharedApplication].statusBarStyle = iOS7Later ? UIStatusBarStyleLightContent : UIStatusBarStyleBlackOpaque;
#pragma clang diagnostic pop
} }
- (void)viewWillDisappear:(BOOL)animated { - (void)viewWillDisappear:(BOOL)animated {
...@@ -164,7 +170,10 @@ ...@@ -164,7 +170,10 @@
[alertController addAction:[UIAlertAction actionWithTitle:@"我知道了" style:UIAlertActionStyleDefault handler:nil]]; [alertController addAction:[UIAlertAction actionWithTitle:@"我知道了" style:UIAlertActionStyleDefault handler:nil]];
[self presentViewController:alertController animated:YES completion:nil]; [self presentViewController:alertController animated:YES completion:nil];
} else { } else {
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
[[[UIAlertView alloc] initWithTitle:title message:nil delegate:nil cancelButtonTitle:@"我知道了" otherButtonTitles:nil, nil] show]; [[[UIAlertView alloc] initWithTitle:title message:nil delegate:nil cancelButtonTitle:@"我知道了" otherButtonTitles:nil, nil] show];
#pragma clang diagnostic pop
} }
} }
...@@ -270,7 +279,11 @@ ...@@ -270,7 +279,11 @@
backButton.titleLabel.font = [UIFont systemFontOfSize:15]; backButton.titleLabel.font = [UIFont systemFontOfSize:15];
[backButton addTarget:self action:@selector(popViewControllerAnimated:) forControlEvents:UIControlEventTouchUpInside]; [backButton addTarget:self action:@selector(popViewControllerAnimated:) forControlEvents:UIControlEventTouchUpInside];
UIBarButtonItem* backButtonItem = [[UIBarButtonItem alloc] initWithCustomView:backButton]; UIBarButtonItem* backButtonItem = [[UIBarButtonItem alloc] initWithCustomView:backButton];
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
backButtonItem.style = UIBarButtonItemStyleBordered; backButtonItem.style = UIBarButtonItemStyleBordered;
#pragma clang diagnostic pop
self.topViewController.navigationItem.backBarButtonItem = backButtonItem; self.topViewController.navigationItem.backBarButtonItem = backButtonItem;
/** /**
......
...@@ -50,8 +50,11 @@ static CGSize AssetGridThumbnailSize; ...@@ -50,8 +50,11 @@ static CGSize AssetGridThumbnailSize;
tzBarItem = [UIBarButtonItem appearanceWhenContainedInInstancesOfClasses:@[[TZImagePickerController class]]]; tzBarItem = [UIBarButtonItem appearanceWhenContainedInInstancesOfClasses:@[[TZImagePickerController class]]];
BarItem = [UIBarButtonItem appearanceWhenContainedInInstancesOfClasses:@[[UIImagePickerController class]]]; BarItem = [UIBarButtonItem appearanceWhenContainedInInstancesOfClasses:@[[UIImagePickerController class]]];
} else { } else {
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
tzBarItem = [UIBarButtonItem appearanceWhenContainedIn:[TZImagePickerController class], nil]; tzBarItem = [UIBarButtonItem appearanceWhenContainedIn:[TZImagePickerController class], nil];
BarItem = [UIBarButtonItem appearanceWhenContainedIn:[UIImagePickerController class], nil]; BarItem = [UIBarButtonItem appearanceWhenContainedIn:[UIImagePickerController class], nil];
#pragma clang diagnostic pop
} }
NSDictionary *titleTextAttributes = [tzBarItem titleTextAttributesForState:UIControlStateNormal]; NSDictionary *titleTextAttributes = [tzBarItem titleTextAttributesForState:UIControlStateNormal];
[BarItem setTitleTextAttributes:titleTextAttributes forState:UIControlStateNormal]; [BarItem setTitleTextAttributes:titleTextAttributes forState:UIControlStateNormal];
...@@ -399,9 +402,12 @@ static CGSize AssetGridThumbnailSize; ...@@ -399,9 +402,12 @@ static CGSize AssetGridThumbnailSize;
- (void)takePhoto { - (void)takePhoto {
AVAuthorizationStatus authStatus = [AVCaptureDevice authorizationStatusForMediaType:AVMediaTypeVideo]; AVAuthorizationStatus authStatus = [AVCaptureDevice authorizationStatusForMediaType:AVMediaTypeVideo];
if ((authStatus == AVAuthorizationStatusRestricted || authStatus ==AVAuthorizationStatusDenied) && iOS8Later) { if ((authStatus == AVAuthorizationStatusRestricted || authStatus ==AVAuthorizationStatusDenied) && iOS8Later) {
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
// 无权限 做一个友好的提示 // 无权限 做一个友好的提示
UIAlertView * alert = [[UIAlertView alloc]initWithTitle:@"无法使用相机" message:@"请在iPhone的""设置-隐私-相机""中允许访问相机" delegate:self cancelButtonTitle:@"取消" otherButtonTitles:@"设置", nil]; UIAlertView * alert = [[UIAlertView alloc]initWithTitle:@"无法使用相机" message:@"请在iPhone的""设置-隐私-相机""中允许访问相机" delegate:self cancelButtonTitle:@"取消" otherButtonTitles:@"设置", nil];
[alert show]; [alert show];
#pragma clang diagnostic pop
} else { // 调用相机 } else { // 调用相机
UIImagePickerControllerSourceType sourceType = UIImagePickerControllerSourceTypeCamera; UIImagePickerControllerSourceType sourceType = UIImagePickerControllerSourceTypeCamera;
if ([UIImagePickerController isSourceTypeAvailable: UIImagePickerControllerSourceTypeCamera]) { if ([UIImagePickerController isSourceTypeAvailable: UIImagePickerControllerSourceTypeCamera]) {
...@@ -497,7 +503,10 @@ static CGSize AssetGridThumbnailSize; ...@@ -497,7 +503,10 @@ static CGSize AssetGridThumbnailSize;
#pragma mark - UIAlertViewDelegate #pragma mark - UIAlertViewDelegate
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex { - (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex {
#pragma clang diagnostic pop
if (buttonIndex == 1) { // 去设置界面,开启相机访问权限 if (buttonIndex == 1) { // 去设置界面,开启相机访问权限
if (iOS8Later) { if (iOS8Later) {
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:UIApplicationOpenSettingsURLString]]; [[UIApplication sharedApplication] openURL:[NSURL URLWithString:UIApplicationOpenSettingsURLString]];
......
...@@ -52,9 +52,12 @@ ...@@ -52,9 +52,12 @@
if ([asset isKindOfClass:[PHAsset class]]) { if ([asset isKindOfClass:[PHAsset class]]) {
PHAsset *phAsset = asset; PHAsset *phAsset = asset;
_videoImageView.hidden = phAsset.mediaType != PHAssetMediaTypeVideo; _videoImageView.hidden = phAsset.mediaType != PHAssetMediaTypeVideo;
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
} else if ([asset isKindOfClass:[ALAsset class]]) { } else if ([asset isKindOfClass:[ALAsset class]]) {
ALAsset *alAsset = asset; ALAsset *alAsset = asset;
_videoImageView.hidden = ![[alAsset valueForProperty:ALAssetPropertyType] isEqualToString:ALAssetTypeVideo]; _videoImageView.hidden = ![[alAsset valueForProperty:ALAssetPropertyType] isEqualToString:ALAssetTypeVideo];
#pragma clang diagnostic pop
} }
} }
......
...@@ -41,7 +41,7 @@ ...@@ -41,7 +41,7 @@
- (UIImagePickerController *)imagePickerVc { - (UIImagePickerController *)imagePickerVc {
if (_imagePickerVc == nil) { if (_imagePickerVc == nil) {
_imagePickerVc = [[UIImagePickerController alloc] init]; _imagePickerVc = [[UIImagePickerController alloc] init];
_imagePickerVc.delegate = self; _imagePickerVc.delegate = self; // *** 这句代码多余的????***
// set appearance / 改变相册选择页的导航栏外观 // set appearance / 改变相册选择页的导航栏外观
_imagePickerVc.navigationBar.barTintColor = self.navigationController.navigationBar.barTintColor; _imagePickerVc.navigationBar.barTintColor = self.navigationController.navigationBar.barTintColor;
_imagePickerVc.navigationBar.tintColor = self.navigationController.navigationBar.tintColor; _imagePickerVc.navigationBar.tintColor = self.navigationController.navigationBar.tintColor;
...@@ -50,8 +50,11 @@ ...@@ -50,8 +50,11 @@
tzBarItem = [UIBarButtonItem appearanceWhenContainedInInstancesOfClasses:@[[TZImagePickerController class]]]; tzBarItem = [UIBarButtonItem appearanceWhenContainedInInstancesOfClasses:@[[TZImagePickerController class]]];
BarItem = [UIBarButtonItem appearanceWhenContainedInInstancesOfClasses:@[[UIImagePickerController class]]]; BarItem = [UIBarButtonItem appearanceWhenContainedInInstancesOfClasses:@[[UIImagePickerController class]]];
} else { } else {
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
tzBarItem = [UIBarButtonItem appearanceWhenContainedIn:[TZImagePickerController class], nil]; tzBarItem = [UIBarButtonItem appearanceWhenContainedIn:[TZImagePickerController class], nil];
BarItem = [UIBarButtonItem appearanceWhenContainedIn:[UIImagePickerController class], nil]; BarItem = [UIBarButtonItem appearanceWhenContainedIn:[UIImagePickerController class], nil];
#pragma clang diagnostic pop
} }
NSDictionary *titleTextAttributes = [tzBarItem titleTextAttributesForState:UIControlStateNormal]; NSDictionary *titleTextAttributes = [tzBarItem titleTextAttributesForState:UIControlStateNormal];
[BarItem setTitleTextAttributes:titleTextAttributes forState:UIControlStateNormal]; [BarItem setTitleTextAttributes:titleTextAttributes forState:UIControlStateNormal];
...@@ -111,7 +114,10 @@ ...@@ -111,7 +114,10 @@
if (indexPath.row == _selectedPhotos.count) { if (indexPath.row == _selectedPhotos.count) {
BOOL showSheet = self.showSheetSwitch.isOn; BOOL showSheet = self.showSheetSwitch.isOn;
if (showSheet) { if (showSheet) {
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
UIActionSheet *sheet = [[UIActionSheet alloc] initWithTitle:nil delegate:self cancelButtonTitle:@"取消" destructiveButtonTitle:nil otherButtonTitles:@"拍照",@"去相册选择", nil]; UIActionSheet *sheet = [[UIActionSheet alloc] initWithTitle:nil delegate:self cancelButtonTitle:@"取消" destructiveButtonTitle:nil otherButtonTitles:@"拍照",@"去相册选择", nil];
#pragma clang diagnostic pop
[sheet showInView:self.view]; [sheet showInView:self.view];
} else { } else {
[self pushImagePickerController]; [self pushImagePickerController];
...@@ -122,9 +128,12 @@ ...@@ -122,9 +128,12 @@
if ([asset isKindOfClass:[PHAsset class]]) { if ([asset isKindOfClass:[PHAsset class]]) {
PHAsset *phAsset = asset; PHAsset *phAsset = asset;
isVideo = phAsset.mediaType == PHAssetMediaTypeVideo; isVideo = phAsset.mediaType == PHAssetMediaTypeVideo;
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
} else if ([asset isKindOfClass:[ALAsset class]]) { } else if ([asset isKindOfClass:[ALAsset class]]) {
ALAsset *alAsset = asset; ALAsset *alAsset = asset;
isVideo = [[alAsset valueForProperty:ALAssetPropertyType] isEqualToString:ALAssetTypeVideo]; isVideo = [[alAsset valueForProperty:ALAssetPropertyType] isEqualToString:ALAssetTypeVideo];
#pragma clang diagnostic pop
} }
if (isVideo) { // perview video / 预览视频 if (isVideo) { // perview video / 预览视频
TZVideoPlayerController *vc = [[TZVideoPlayerController alloc] init]; TZVideoPlayerController *vc = [[TZVideoPlayerController alloc] init];
...@@ -201,8 +210,11 @@ ...@@ -201,8 +210,11 @@
AVAuthorizationStatus authStatus = [AVCaptureDevice authorizationStatusForMediaType:AVMediaTypeVideo]; AVAuthorizationStatus authStatus = [AVCaptureDevice authorizationStatusForMediaType:AVMediaTypeVideo];
if ((authStatus == AVAuthorizationStatusRestricted || authStatus == AVAuthorizationStatusDenied) && iOS8Later) { if ((authStatus == AVAuthorizationStatusRestricted || authStatus == AVAuthorizationStatusDenied) && iOS8Later) {
// 无权限 做一个友好的提示 // 无权限 做一个友好的提示
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
UIAlertView * alert = [[UIAlertView alloc]initWithTitle:@"无法使用相机" message:@"请在iPhone的""设置-隐私-相机""中允许访问相机" delegate:self cancelButtonTitle:@"取消" otherButtonTitles:@"设置", nil]; UIAlertView * alert = [[UIAlertView alloc]initWithTitle:@"无法使用相机" message:@"请在iPhone的""设置-隐私-相机""中允许访问相机" delegate:self cancelButtonTitle:@"取消" otherButtonTitles:@"设置", nil];
[alert show]; [alert show];
#define push @#clang diagnostic pop
} else { // 调用相机 } else { // 调用相机
UIImagePickerControllerSourceType sourceType = UIImagePickerControllerSourceTypeCamera; UIImagePickerControllerSourceType sourceType = UIImagePickerControllerSourceTypeCamera;
if ([UIImagePickerController isSourceTypeAvailable: UIImagePickerControllerSourceTypeCamera]) { if ([UIImagePickerController isSourceTypeAvailable: UIImagePickerControllerSourceTypeCamera]) {
...@@ -249,7 +261,10 @@ ...@@ -249,7 +261,10 @@
#pragma mark - UIActionSheetDelegate #pragma mark - UIActionSheetDelegate
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
- (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex { - (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex {
#pragma clang diagnostic pop
if (buttonIndex == 0) { // take photo / 去拍照 if (buttonIndex == 0) { // take photo / 去拍照
[self takePhoto]; [self takePhoto];
} else if (buttonIndex == 1) { } else if (buttonIndex == 1) {
...@@ -259,7 +274,10 @@ ...@@ -259,7 +274,10 @@
#pragma mark - UIAlertViewDelegate #pragma mark - UIAlertViewDelegate
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex { - (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex {
#pragma clang diagnostic pop
if (buttonIndex == 1) { // 去设置界面,开启相机访问权限 if (buttonIndex == 1) { // 去设置界面,开启相机访问权限
if (iOS8Later) { if (iOS8Later) {
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:UIApplicationOpenSettingsURLString]]; [[UIApplication sharedApplication] openURL:[NSURL URLWithString:UIApplicationOpenSettingsURLString]];
......
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