Commit eaa156c2 authored by tanzhen's avatar tanzhen

修复几个已知bug

parent 017e1e86
Pod::Spec.new do |s| Pod::Spec.new do |s|
s.name = "TZImagePickerController" s.name = "TZImagePickerController"
s.version = "1.0.6" s.version = "1.0.7"
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" => "736420282@qq.com" } s.author = { "banchichen" => "736420282@qq.com" }
s.platform = :ios s.platform = :ios
s.ios.deployment_target = "6.0" s.ios.deployment_target = "6.0"
s.source = { :git => "https://github.com/banchichen/TZImagePickerController.git", :tag => "1.0.6" } s.source = { :git => "https://github.com/banchichen/TZImagePickerController.git", :tag => "1.0.7" }
s.requires_arc = true s.requires_arc = true
s.resources = "TZImagePickerController/TZImagePickerController/Resource/*.{png,xib,nib}" s.resources = "TZImagePickerController/TZImagePickerController/Resource/*.{png,xib,nib}"
s.source_files = "TZImagePickerController/TZImagePickerController/*.{h,m}" s.source_files = "TZImagePickerController/TZImagePickerController/*.{h,m}"
......
...@@ -30,6 +30,7 @@ ...@@ -30,6 +30,7 @@
- (void)getPostImageWithAlbumModel:(TZAlbumModel *)model completion:(void (^)(UIImage *postImage))completion; - (void)getPostImageWithAlbumModel:(TZAlbumModel *)model completion:(void (^)(UIImage *postImage))completion;
- (void)getPhotoWithAsset:(id)asset completion:(void (^)(UIImage *photo,NSDictionary *info,BOOL isDegraded))completion; - (void)getPhotoWithAsset:(id)asset completion:(void (^)(UIImage *photo,NSDictionary *info,BOOL isDegraded))completion;
- (void)getPhotoWithAsset:(id)asset photoWidth:(CGFloat)photoWidth completion:(void (^)(UIImage *photo,NSDictionary *info,BOOL isDegraded))completion; - (void)getPhotoWithAsset:(id)asset photoWidth:(CGFloat)photoWidth completion:(void (^)(UIImage *photo,NSDictionary *info,BOOL isDegraded))completion;
- (void)getOriginalPhotoWithAsset:(id)asset completion:(void (^)(UIImage *photo,NSDictionary *info))completion;
/// Get video 获得视频 /// Get video 获得视频
- (void)getVideoWithAsset:(id)asset completion:(void (^)(AVPlayerItem * playerItem, NSDictionary * info))completion; - (void)getVideoWithAsset:(id)asset completion:(void (^)(AVPlayerItem * playerItem, NSDictionary * info))completion;
......
...@@ -144,6 +144,7 @@ ...@@ -144,6 +144,7 @@
// if (asset.mediaSubtypes == PHAssetMediaSubtypePhotoLive) type = TZAssetModelMediaTypeLivePhoto; // if (asset.mediaSubtypes == PHAssetMediaSubtypePhotoLive) type = TZAssetModelMediaTypeLivePhoto;
} }
} }
if (!allowPickingVideo && type == TZAssetModelMediaTypeVideo) return;
NSString *timeLength = type == TZAssetModelMediaTypeVideo ? [NSString stringWithFormat:@"%0.0f",asset.duration] : @""; NSString *timeLength = type == TZAssetModelMediaTypeVideo ? [NSString stringWithFormat:@"%0.0f",asset.duration] : @"";
timeLength = [self getNewTimeFromDurationSecond:timeLength.integerValue]; timeLength = [self getNewTimeFromDurationSecond:timeLength.integerValue];
[photoArr addObject:[TZAssetModel modelWithAsset:asset type:type timeLength:timeLength]]; [photoArr addObject:[TZAssetModel modelWithAsset:asset type:type timeLength:timeLength]];
...@@ -282,13 +283,17 @@ ...@@ -282,13 +283,17 @@
} }
- (void)getPhotoWithAsset:(id)asset photoWidth:(CGFloat)photoWidth completion:(void (^)(UIImage *, NSDictionary *, BOOL isDegraded))completion { - (void)getPhotoWithAsset:(id)asset photoWidth:(CGFloat)photoWidth completion:(void (^)(UIImage *, NSDictionary *, BOOL isDegraded))completion {
if (photoWidth > 600) photoWidth = 600.0;
if ([asset isKindOfClass:[PHAsset class]]) { if ([asset isKindOfClass:[PHAsset class]]) {
PHAsset *phAsset = (PHAsset *)asset; PHAsset *phAsset = (PHAsset *)asset;
CGFloat aspectRatio = phAsset.pixelWidth / (CGFloat)phAsset.pixelHeight; CGFloat aspectRatio = phAsset.pixelWidth / (CGFloat)phAsset.pixelHeight;
CGFloat multiple = [UIScreen mainScreen].scale; CGFloat multiple = [UIScreen mainScreen].scale;
CGFloat pixelWidth = photoWidth * multiple; CGFloat pixelWidth = photoWidth * multiple;
CGFloat pixelHeight = pixelWidth / aspectRatio; CGFloat pixelHeight = pixelWidth / aspectRatio;
[[PHImageManager defaultManager] requestImageForAsset:asset targetSize:CGSizeMake(pixelWidth, pixelHeight) contentMode:PHImageContentModeAspectFit options:nil resultHandler:^(UIImage * _Nullable result, NSDictionary * _Nullable info) {
PHImageRequestOptions *option = [[PHImageRequestOptions alloc]init];
option.networkAccessAllowed = YES;
[[PHImageManager defaultManager] requestImageForAsset:asset targetSize:CGSizeMake(pixelWidth, pixelHeight) contentMode:PHImageContentModeAspectFit options:option resultHandler:^(UIImage * _Nullable result, NSDictionary * _Nullable info) {
BOOL downloadFinined = (![[info objectForKey:PHImageCancelledKey] boolValue] && ![info objectForKey:PHImageErrorKey]); BOOL downloadFinined = (![[info objectForKey:PHImageCancelledKey] boolValue] && ![info objectForKey:PHImageErrorKey]);
if (downloadFinined) { if (downloadFinined) {
if (completion) completion(result,info,[[info objectForKey:PHImageResultIsDegradedKey] boolValue]); if (completion) completion(result,info,[[info objectForKey:PHImageResultIsDegradedKey] boolValue]);
...@@ -326,6 +331,32 @@ ...@@ -326,6 +331,32 @@
} }
} }
/// Get Original Photo / 获取原图
- (void)getOriginalPhotoWithAsset:(id)asset completion:(void (^)(UIImage *photo,NSDictionary *info))completion {
if ([asset isKindOfClass:[PHAsset class]]) {
PHImageRequestOptions *option = [[PHImageRequestOptions alloc]init];
option.networkAccessAllowed = YES;
[[PHImageManager defaultManager] requestImageForAsset:asset targetSize:PHImageManagerMaximumSize contentMode:PHImageContentModeAspectFit options:option resultHandler:^(UIImage * _Nullable result, NSDictionary * _Nullable info) {
BOOL downloadFinined = (![[info objectForKey:PHImageCancelledKey] boolValue] && ![info objectForKey:PHImageErrorKey]);
if (downloadFinined) {
if (completion) completion(result,info);
}
}];
} else if ([asset isKindOfClass:[ALAsset class]]) {
ALAsset *alAsset = (ALAsset *)asset;
ALAssetRepresentation *assetRep = [alAsset defaultRepresentation];
dispatch_async(dispatch_get_global_queue(0,0), ^{
CGImageRef originalImageRef = [assetRep fullResolutionImage];
UIImage *originalImage = [UIImage imageWithCGImage:originalImageRef scale:1.0 orientation:UIImageOrientationUp];
dispatch_async(dispatch_get_main_queue(), ^{
if (completion) completion(originalImage,nil);
});
});
}
}
#pragma mark - Get Video #pragma mark - Get Video
- (void)getVideoWithAsset:(id)asset completion:(void (^)(AVPlayerItem * _Nullable, NSDictionary * _Nullable))completion { - (void)getVideoWithAsset:(id)asset completion:(void (^)(AVPlayerItem * _Nullable, NSDictionary * _Nullable))completion {
......
...@@ -8,9 +8,6 @@ ...@@ -8,9 +8,6 @@
#import <UIKit/UIKit.h> #import <UIKit/UIKit.h>
#define kNaviBarAndBottonBarBgColor ([UIColor colorWithRed:(34/255.0) green:(34/255.0) blue:(34/255.0) alpha:1.0])
#define kOKButtonTitleColorNormal ([UIColor colorWithRed:(83/255.0) green:(179/255.0) blue:(17/255.0) alpha:1.0])
#define kOKButtonTitleColorDisabled ([UIColor colorWithRed:(83/255.0) green:(179/255.0) blue:(17/255.0) alpha:0.5])
#define iOS7Later ([UIDevice currentDevice].systemVersion.floatValue >= 7.0f) #define iOS7Later ([UIDevice currentDevice].systemVersion.floatValue >= 7.0f)
#define iOS8Later ([UIDevice currentDevice].systemVersion.floatValue >= 8.0f) #define iOS8Later ([UIDevice currentDevice].systemVersion.floatValue >= 8.0f)
#define iOS9Later ([UIDevice currentDevice].systemVersion.floatValue >= 9.0f) #define iOS9Later ([UIDevice currentDevice].systemVersion.floatValue >= 9.0f)
...@@ -37,6 +34,10 @@ ...@@ -37,6 +34,10 @@
- (void)showProgressHUD; - (void)showProgressHUD;
- (void)hideProgressHUD; - (void)hideProgressHUD;
/// Appearance / 外观颜色
@property (nonatomic, strong) UIColor *oKButtonTitleColorNormal;
@property (nonatomic, strong) UIColor *oKButtonTitleColorDisabled;
// The picker does not dismiss itself; when client dismisses it these handle will be called. // The picker does not dismiss itself; when client dismisses it these handle will be called.
// The second array will be a empty array if user not picking original photo. // The second array will be a empty array if user not picking original photo.
// 这个照片选择器不会自己dismiss,用户dismiss这个选择器的时候,会执行下面的handle // 这个照片选择器不会自己dismiss,用户dismiss这个选择器的时候,会执行下面的handle
......
...@@ -36,8 +36,13 @@ ...@@ -36,8 +36,13 @@
[UIApplication sharedApplication].statusBarStyle = UIStatusBarStyleLightContent; [UIApplication sharedApplication].statusBarStyle = UIStatusBarStyleLightContent;
[UIApplication sharedApplication].statusBarHidden = NO; [UIApplication sharedApplication].statusBarHidden = NO;
// Default appearance, you can reset these after this method
// 默认的外观,你可以在这个方法后重置
self.oKButtonTitleColorNormal = [UIColor colorWithRed:(83/255.0) green:(179/255.0) blue:(17/255.0) alpha:1.0];
self.oKButtonTitleColorDisabled = [UIColor colorWithRed:(83/255.0) green:(179/255.0) blue:(17/255.0) alpha:0.5];
if (iOS7Later) { if (iOS7Later) {
self.navigationBar.barTintColor = kNaviBarAndBottonBarBgColor; self.navigationBar.barTintColor = [UIColor colorWithRed:(34/255.0) green:(34/255.0) blue:(34/255.0) alpha:1.0];
self.navigationBar.tintColor = [UIColor whiteColor]; self.navigationBar.tintColor = [UIColor whiteColor];
self.automaticallyAdjustsScrollViewInsets = NO; self.automaticallyAdjustsScrollViewInsets = NO;
} }
......
...@@ -127,8 +127,8 @@ ...@@ -127,8 +127,8 @@
[_okButton addTarget:self action:@selector(okButtonClick) forControlEvents:UIControlEventTouchUpInside]; [_okButton addTarget:self action:@selector(okButtonClick) forControlEvents:UIControlEventTouchUpInside];
[_okButton setTitle:@"确定" forState:UIControlStateNormal]; [_okButton setTitle:@"确定" forState:UIControlStateNormal];
[_okButton setTitle:@"确定" forState:UIControlStateDisabled]; [_okButton setTitle:@"确定" forState:UIControlStateDisabled];
[_okButton setTitleColor:kOKButtonTitleColorNormal forState:UIControlStateNormal]; [_okButton setTitleColor:imagePickerVc.oKButtonTitleColorNormal forState:UIControlStateNormal];
[_okButton setTitleColor:kOKButtonTitleColorDisabled forState:UIControlStateDisabled]; [_okButton setTitleColor:imagePickerVc.oKButtonTitleColorDisabled forState:UIControlStateDisabled];
_okButton.enabled = NO; _okButton.enabled = NO;
_numberImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"photo_number_icon"]]; _numberImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"photo_number_icon"]];
......
...@@ -60,8 +60,13 @@ ...@@ -60,8 +60,13 @@
} }
- (void)configCustomNaviBar { - (void)configCustomNaviBar {
<<<<<<< 017e1e86a308ce3cc61250052da3d23d4c681a5c
_naviBar = [[UIView alloc] initWithFrame:CGRectMake(0, 0, self.view.tz_width, 64)]; _naviBar = [[UIView alloc] initWithFrame:CGRectMake(0, 0, self.view.tz_width, 64)];
_naviBar.backgroundColor = kNaviBarAndBottonBarBgColor; _naviBar.backgroundColor = kNaviBarAndBottonBarBgColor;
=======
_naviBar = [[UIView alloc] initWithFrame:CGRectMake(0, 0, self.view.width, 64)];
_naviBar.backgroundColor = [UIColor colorWithRed:(34/255.0) green:(34/255.0) blue:(34/255.0) alpha:1.0];
>>>>>>> 修复几个已知bug:
_naviBar.alpha = 0.7; _naviBar.alpha = 0.7;
_backButton = [[UIButton alloc] initWithFrame:CGRectMake(10, 10, 44, 44)]; _backButton = [[UIButton alloc] initWithFrame:CGRectMake(10, 10, 44, 44)];
...@@ -115,7 +120,7 @@ ...@@ -115,7 +120,7 @@
_okButton.titleLabel.font = [UIFont systemFontOfSize:16]; _okButton.titleLabel.font = [UIFont systemFontOfSize:16];
[_okButton addTarget:self action:@selector(okButtonClick) forControlEvents:UIControlEventTouchUpInside]; [_okButton addTarget:self action:@selector(okButtonClick) forControlEvents:UIControlEventTouchUpInside];
[_okButton setTitle:@"确定" forState:UIControlStateNormal]; [_okButton setTitle:@"确定" forState:UIControlStateNormal];
[_okButton setTitleColor:kOKButtonTitleColorNormal forState:UIControlStateNormal]; [_okButton setTitleColor:imagePickerVc.oKButtonTitleColorNormal forState:UIControlStateNormal];
_numberImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"photo_number_icon"]]; _numberImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"photo_number_icon"]];
_numberImageView.backgroundColor = [UIColor clearColor]; _numberImageView.backgroundColor = [UIColor clearColor];
......
...@@ -85,7 +85,8 @@ ...@@ -85,7 +85,8 @@
_okButton.titleLabel.font = [UIFont systemFontOfSize:16]; _okButton.titleLabel.font = [UIFont systemFontOfSize:16];
[_okButton addTarget:self action:@selector(okButtonClick) forControlEvents:UIControlEventTouchUpInside]; [_okButton addTarget:self action:@selector(okButtonClick) forControlEvents:UIControlEventTouchUpInside];
[_okButton setTitle:@"确定" forState:UIControlStateNormal]; [_okButton setTitle:@"确定" forState:UIControlStateNormal];
[_okButton setTitleColor:kOKButtonTitleColorNormal forState:UIControlStateNormal]; TZImagePickerController *imagePickerVc = (TZImagePickerController *)self.navigationController;
[_okButton setTitleColor:imagePickerVc.oKButtonTitleColorNormal forState:UIControlStateNormal];
[_toolBar addSubview:_okButton]; [_toolBar addSubview:_okButton];
[self.view addSubview:_toolBar]; [self.view addSubview:_toolBar];
......
...@@ -80,6 +80,17 @@ ...@@ -80,6 +80,17 @@
}]; }];
// Set the appearance
// 在这里设置imagePickerVc的外观
// imagePickerVc.navigationBar.barTintColor = [UIColor greenColor];
// imagePickerVc.oKButtonTitleColorDisabled = [UIColor lightGrayColor];
// imagePickerVc.oKButtonTitleColorNormal = [UIColor greenColor];
// Set allow picking video & originalPhoto or not
// 设置是否可以选择视频/原图
// imagePickerVc.allowPickingVideo = NO;
// imagePickerVc.allowPickingOriginalPhoto = NO;
[self presentViewController:imagePickerVc animated:YES completion:nil]; [self presentViewController:imagePickerVc animated:YES completion:nil];
} }
......
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