Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #224 from roverdotcom/master
Fix missing thumbnails for iOS 9.3+
- Loading branch information
Showing
8 changed files
with
73 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 15 additions & 0 deletions
15
CTAssetsPickerController/Categories/PHImageManager+CTAssetsPickerController.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
// | ||
// PHImageManager+CTSupport.h | ||
// CTAssetsPickerDemo | ||
// | ||
// Created by Korben Allen Rusek on 4/7/16. | ||
// Copyright © 2016 Clement T. All rights reserved. | ||
// | ||
|
||
#import <Photos/Photos.h> | ||
|
||
@interface PHImageManager (CTAssetsPickerController) | ||
|
||
- (PHImageRequestID)ctassetsPickerRequestImageForAsset:(PHAsset *)asset targetSize:(CGSize)targetSize contentMode:(PHImageContentMode)contentMode options:( PHImageRequestOptions *)options resultHandler:(void (^)(UIImage * result, NSDictionary * info))resultHandler; | ||
|
||
@end |
40 changes: 40 additions & 0 deletions
40
CTAssetsPickerController/Categories/PHImageManager+CTAssetsPickerController.m
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
// | ||
// PHImageManager+CTSupport.m | ||
// CTAssetsPickerDemo | ||
// | ||
// Created by Korben Allen Rusek on 4/7/16. | ||
// Copyright © 2016 Clement T. All rights reserved. | ||
// | ||
|
||
#import "PHImageManager+CTAssetsPickerController.h" | ||
|
||
@implementation PHImageManager (CTAssetsPickerController) | ||
|
||
+ (BOOL)ctassetsPickerNeedsiPadSupportSize { | ||
return [(NSString*)[UIDevice currentDevice].model hasPrefix:@"iPad"] && UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad == false; | ||
} | ||
|
||
+ (CGSize)ctassetsPickerSizeForSize:(CGSize)size withMinimumDimension:(CGFloat)dimension { | ||
if (size.width >= dimension && size.height >= dimension) return size; | ||
if (size.width <= 0 || size.height <= 0) return size; | ||
|
||
CGFloat width, height; | ||
if (size.width < size.height) { | ||
width = 500; | ||
height = size.height/size.width*width; | ||
} else { | ||
height = 500; | ||
width = size.width/size.height*height; | ||
} | ||
return CGSizeMake(width, height); | ||
} | ||
|
||
- (PHImageRequestID)ctassetsPickerRequestImageForAsset:(PHAsset *)asset targetSize:(CGSize)targetSize contentMode:(PHImageContentMode)contentMode options:( PHImageRequestOptions *)options resultHandler:(void (^)(UIImage * result, NSDictionary * info))resultHandler { | ||
CGSize size = targetSize; | ||
if ([[self class] ctassetsPickerNeedsiPadSupportSize]) { | ||
size = [[self class] ctassetsPickerSizeForSize:targetSize withMinimumDimension:500]; | ||
} | ||
return [self requestImageForAsset:asset targetSize:size contentMode:contentMode options:options resultHandler:resultHandler]; | ||
} | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters