Commit 39467b90 authored by yuzheng.tz's avatar yuzheng.tz

发布版本1.8.4 加入横竖屏适配

parent 2b8633e1
Pod::Spec.new do |s|
s.name = "TZImagePickerController"
s.version = "1.8.3"
s.version = "1.8.4"
s.summary = "A clone of UIImagePickerController, support picking multiple photos、original photo and video"
s.homepage = "https://github.com/banchichen/TZImagePickerController"
s.license = "MIT"
s.author = { "banchichen" => "tanzhenios@foxmail.com" }
s.platform = :ios
s.ios.deployment_target = "6.0"
s.source = { :git => "https://github.com/banchichen/TZImagePickerController.git", :tag => "1.8.3" }
s.source = { :git => "https://github.com/banchichen/TZImagePickerController.git", :tag => "1.8.4" }
s.requires_arc = true
s.resources = "TZImagePickerController/TZImagePickerController/*.{png,xib,nib,bundle}"
s.source_files = "TZImagePickerController/TZImagePickerController/*.{h,m}"
......
......@@ -3,7 +3,7 @@
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<string>en_US</string>
<key>CFBundleExecutable</key>
<string>$(EXECUTABLE_NAME)</string>
<key>CFBundleIdentifier</key>
......@@ -15,7 +15,7 @@
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>1.8.3</string>
<string>1.8.4</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
......
......@@ -153,7 +153,6 @@
- (UIButton *)selectPhotoButton {
if (_selectImageView == nil) {
UIButton *selectPhotoButton = [[UIButton alloc] init];
selectPhotoButton.frame = CGRectMake(self.tz_width - 44, 0, 44, 44);
[selectPhotoButton addTarget:self action:@selector(selectPhotoButtonClick:) forControlEvents:UIControlEventTouchUpInside];
[self.contentView addSubview:selectPhotoButton];
_selectPhotoButton = selectPhotoButton;
......@@ -164,7 +163,6 @@
- (UIImageView *)imageView {
if (_imageView == nil) {
UIImageView *imageView = [[UIImageView alloc] init];
imageView.frame = CGRectMake(0, 0, self.tz_width, self.tz_height);
imageView.contentMode = UIViewContentModeScaleAspectFill;
imageView.clipsToBounds = YES;
[self.contentView addSubview:imageView];
......@@ -179,7 +177,6 @@
- (UIImageView *)selectImageView {
if (_selectImageView == nil) {
UIImageView *selectImageView = [[UIImageView alloc] init];
selectImageView.frame = CGRectMake(self.tz_width - 27, 0, 27, 27);
[self.contentView addSubview:selectImageView];
_selectImageView = selectImageView;
}
......@@ -189,7 +186,6 @@
- (UIView *)bottomView {
if (_bottomView == nil) {
UIView *bottomView = [[UIView alloc] init];
bottomView.frame = CGRectMake(0, self.tz_height - 17, self.tz_width, 17);
static NSInteger rgb = 0;
bottomView.backgroundColor = [UIColor colorWithRed:rgb green:rgb blue:rgb alpha:0.8];
[self.contentView addSubview:bottomView];
......@@ -201,7 +197,6 @@
- (UIImageView *)videoImgView {
if (_videoImgView == nil) {
UIImageView *videoImgView = [[UIImageView alloc] init];
videoImgView.frame = CGRectMake(8, 0, 17, 17);
[videoImgView setImage:[UIImage imageNamedFromMyBundle:@"VideoSendIcon.png"]];
[self.bottomView addSubview:videoImgView];
_videoImgView = videoImgView;
......@@ -213,7 +208,6 @@
if (_timeLength == nil) {
UILabel *timeLength = [[UILabel alloc] init];
timeLength.font = [UIFont boldSystemFontOfSize:11];
timeLength.frame = CGRectMake(self.videoImgView.tz_right, 0, self.tz_width - self.videoImgView.tz_right - 5, 17);
timeLength.textColor = [UIColor whiteColor];
timeLength.textAlignment = NSTextAlignmentRight;
[self.bottomView addSubview:timeLength];
......@@ -225,15 +219,30 @@
- (TZProgressView *)progressView {
if (_progressView == nil) {
_progressView = [[TZProgressView alloc] init];
static CGFloat progressWH = 20;
CGFloat progressXY = (self.tz_width - progressWH) / 2;
_progressView.hidden = YES;
_progressView.frame = CGRectMake(progressXY, progressXY, progressWH, progressWH);
[self addSubview:_progressView];
}
return _progressView;
}
- (void)layoutSubviews {
[super layoutSubviews];
_selectPhotoButton.frame = CGRectMake(self.tz_width - 44, 0, 44, 44);
_selectImageView.frame = CGRectMake(self.tz_width - 27, 0, 27, 27);
_imageView.frame = CGRectMake(0, 0, self.tz_width, self.tz_height);
static CGFloat progressWH = 20;
CGFloat progressXY = (self.tz_width - progressWH) / 2;
_progressView.frame = CGRectMake(progressXY, progressXY, progressWH, progressWH);
_bottomView.frame = CGRectMake(0, self.tz_height - 17, self.tz_width, 17);
_videoImgView.frame = CGRectMake(8, 0, 17, 17);
_timeLength.frame = CGRectMake(self.videoImgView.tz_right, 0, self.tz_width - self.videoImgView.tz_right - 5, 17);
self.type = (NSInteger)self.model.type;
self.showSelectBtn = self.showSelectBtn;
}
@end
@interface TZAlbumCell ()
......
......@@ -52,8 +52,7 @@
}
- (void)configPreviewView {
_previewView = [[TZPhotoPreviewView alloc] initWithFrame:self.view.bounds];
_previewView.scrollView.frame = self.view.bounds;
_previewView = [[TZPhotoPreviewView alloc] initWithFrame:CGRectZero];
_previewView.model = self.model;
__weak typeof(self) weakSelf = self;
[_previewView setSingleTapGestureBlock:^{
......@@ -63,12 +62,11 @@
}
- (void)configBottomToolBar {
_toolBar = [[UIView alloc] initWithFrame:CGRectMake(0, self.view.tz_height - 44, self.view.tz_width, 44)];
_toolBar = [[UIView alloc] initWithFrame:CGRectZero];
CGFloat rgb = 34 / 255.0;
_toolBar.backgroundColor = [UIColor colorWithRed:rgb green:rgb blue:rgb alpha:0.7];
_doneButton = [UIButton buttonWithType:UIButtonTypeCustom];
_doneButton.frame = CGRectMake(self.view.tz_width - 44 - 12, 0, 44, 44);
_doneButton.titleLabel.font = [UIFont systemFontOfSize:16];
[_doneButton addTarget:self action:@selector(doneButtonClick) forControlEvents:UIControlEventTouchUpInside];
TZImagePickerController *tzImagePickerVc = (TZImagePickerController *)self.navigationController;
......@@ -93,6 +91,17 @@
[self.view addSubview:_toolBar];
}
#pragma mark - Layout
- (void)viewDidLayoutSubviews {
[super viewDidLayoutSubviews];
_previewView.frame = self.view.bounds;
_previewView.scrollView.frame = self.view.bounds;
_doneButton.frame = CGRectMake(self.view.tz_width - 44 - 12, 0, 44, 44);
_toolBar.frame = CGRectMake(0, self.view.tz_height - 44, self.view.tz_width, 44);
}
#pragma mark - Click Event
- (void)signleTapAction {
......
......@@ -19,9 +19,9 @@
@implementation TZImageManager
static CGSize AssetGridThumbnailSize;
static CGFloat TZScreenWidth;
static CGFloat TZScreenScale;
CGSize AssetGridThumbnailSize;
CGFloat TZScreenWidth;
CGFloat TZScreenScale;
static TZImageManager *manager;
static dispatch_once_t onceToken;
......@@ -34,12 +34,7 @@ static dispatch_once_t onceToken;
// manager.cachingImageManager.allowsCachingHighQualityImages = YES;
}
TZScreenWidth = [UIScreen mainScreen].bounds.size.width;
// 测试发现,如果scale在plus真机上取到3.0,内存会增大特别多。故这里写死成2.0
TZScreenScale = 2.0;
if (TZScreenWidth > 700) {
TZScreenScale = 1.5;
}
[manager configTZScreenWidth];
});
return manager;
}
......@@ -55,12 +50,23 @@ static dispatch_once_t onceToken;
}
- (void)setColumnNumber:(NSInteger)columnNumber {
[self configTZScreenWidth];
_columnNumber = columnNumber;
CGFloat margin = 4;
CGFloat itemWH = (TZScreenWidth - 2 * margin - 4) / columnNumber - margin;
AssetGridThumbnailSize = CGSizeMake(itemWH * TZScreenScale, itemWH * TZScreenScale);
}
- (void)configTZScreenWidth {
TZScreenWidth = [UIScreen mainScreen].bounds.size.width;
// 测试发现,如果scale在plus真机上取到3.0,内存会增大特别多。故这里写死成2.0
TZScreenScale = 2.0;
if (TZScreenWidth > 700) {
TZScreenScale = 1.5;
}
}
- (ALAssetsLibrary *)assetLibrary {
if (_assetLibrary == nil) _assetLibrary = [[ALAssetsLibrary alloc] init];
return _assetLibrary;
......@@ -450,7 +456,7 @@ static dispatch_once_t onceToken;
CGFloat aspectRatio = phAsset.pixelWidth / (CGFloat)phAsset.pixelHeight;
CGFloat pixelWidth = photoWidth * TZScreenScale * 1.5;
// 超宽图片
if (aspectRatio > 1) {
if (aspectRatio > 1.8) {
pixelWidth = pixelWidth * aspectRatio;
}
// 超高图片
......
......@@ -4,7 +4,7 @@
//
// Created by 谭真 on 15/12/24.
// Copyright © 2015年 谭真. All rights reserved.
// version 1.8.3 - 2017.07.15
// version 1.8.4 - 2017.07.22
// 更多信息,请前往项目的github地址:https://github.com/banchichen/TZImagePickerController
/*
......
......@@ -4,7 +4,7 @@
//
// Created by 谭真 on 15/12/24.
// Copyright © 2015年 谭真. All rights reserved.
// version 1.8.3 - 2017.07.15
// version 1.8.4 - 2017.07.22
// 更多信息,请前往项目的github地址:https://github.com/banchichen/TZImagePickerController
#import "TZImagePickerController.h"
......@@ -45,7 +45,6 @@
self.navigationBar.translucent = YES;
[TZImageManager manager].shouldFixOrientation = 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];
......@@ -112,7 +111,6 @@
}else{
[UIApplication sharedApplication].statusBarStyle = iOS7Later ? UIStatusBarStyleLightContent : UIStatusBarStyleBlackOpaque;
}
}
- (void)viewWillDisappear:(BOOL)animated {
......@@ -319,17 +317,14 @@
[_progressHUD setBackgroundColor:[UIColor clearColor]];
_HUDContainer = [[UIView alloc] init];
_HUDContainer.frame = CGRectMake((self.view.tz_width - 120) / 2, (self.view.tz_height - 90) / 2, 120, 90);
_HUDContainer.layer.cornerRadius = 8;
_HUDContainer.clipsToBounds = YES;
_HUDContainer.backgroundColor = [UIColor darkGrayColor];
_HUDContainer.alpha = 0.7;
_HUDIndicatorView = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhite];
_HUDIndicatorView.frame = CGRectMake(45, 15, 30, 30);
_HUDLabel = [[UILabel alloc] init];
_HUDLabel.frame = CGRectMake(0,40, 120, 50);
_HUDLabel.textAlignment = NSTextAlignmentCenter;
_HUDLabel.text = self.processHintStr;
_HUDLabel.font = [UIFont systemFontOfSize:15];
......@@ -389,8 +384,8 @@
if (_cropRect.size.width > 0) {
return _cropRect;
}
CGFloat cropViewWH = self.view.tz_width;
return CGRectMake(0, (self.view.tz_height - self.view.tz_width) / 2, cropViewWH, cropViewWH);
CGFloat cropViewWH = MIN(self.view.tz_width, self.view.tz_height) / 3 * 2;
return CGRectMake((self.view.tz_width - cropViewWH) / 2, (self.view.tz_height - cropViewWH) / 2, cropViewWH, cropViewWH);
}
- (void)setTimeout:(NSInteger)timeout {
......@@ -500,14 +495,40 @@
[super pushViewController:viewController animated:animated];
}
- (UIInterfaceOrientationMask)supportedInterfaceOrientations {
return UIInterfaceOrientationMaskPortrait;
}
- (void)dealloc {
// NSLog(@"%@ dealloc",NSStringFromClass(self.class));
}
#pragma mark - UIContentContainer
- (void)viewWillTransitionToSize:(CGSize)size withTransitionCoordinator:(id<UIViewControllerTransitionCoordinator>)coordinator {
if (![UIApplication sharedApplication].statusBarHidden) {
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.01 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
if (iOS7Later && !TZ_isGlobalHideStatusBar) [UIApplication sharedApplication].statusBarHidden = NO;
});
}
self.cropRect = CGRectZero;
}
- (void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration {
if (![UIApplication sharedApplication].statusBarHidden) {
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.01 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
if (iOS7Later && !TZ_isGlobalHideStatusBar) [UIApplication sharedApplication].statusBarHidden = NO;
});
}
self.cropRect = CGRectZero;
}
#pragma mark - Layout
- (void)viewDidLayoutSubviews {
[super viewDidLayoutSubviews];
_HUDContainer.frame = CGRectMake((self.view.tz_width - 120) / 2, (self.view.tz_height - 90) / 2, 120, 90);
_HUDIndicatorView.frame = CGRectMake(45, 15, 30, 30);
_HUDLabel.frame = CGRectMake(0,40, 120, 50);
}
#pragma mark - Public
- (void)cancelButtonClick {
......@@ -521,12 +542,6 @@
}
- (void)callDelegateMethod {
/*
// 兼容旧版本
if ([self.pickerDelegate respondsToSelector:@selector(imagePickerControllerDidCancel:)]) {
[self.pickerDelegate imagePickerControllerDidCancel:self];
}
*/
if ([self.pickerDelegate respondsToSelector:@selector(tz_imagePickerControllerDidCancel:)]) {
[self.pickerDelegate tz_imagePickerControllerDidCancel:self];
}
......@@ -586,19 +601,7 @@
dispatch_async(dispatch_get_main_queue(), ^{
if (!_tableView) {
CGFloat top = 0;
CGFloat tableViewHeight = 0;
if (self.navigationController.navigationBar.isTranslucent) {
top = 44;
if (iOS7Later && !TZ_isGlobalHideStatusBar) top += 20;
tableViewHeight = self.view.tz_height - top;
} else {
CGFloat navigationHeight = 44;
if (iOS7Later && !TZ_isGlobalHideStatusBar) navigationHeight += 20;
tableViewHeight = self.view.tz_height - navigationHeight;
}
_tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, top, self.view.tz_width, tableViewHeight) style:UITableViewStylePlain];
_tableView = [[UITableView alloc] initWithFrame:CGRectZero style:UITableViewStylePlain];
_tableView.rowHeight = 70;
_tableView.tableFooterView = [[UIView alloc] init];
_tableView.dataSource = self;
......@@ -617,6 +620,26 @@
// NSLog(@"%@ dealloc",NSStringFromClass(self.class));
}
#pragma mark - Layout
- (void)viewDidLayoutSubviews {
[super viewDidLayoutSubviews];
CGFloat top = 0;
CGFloat tableViewHeight = 0;
CGFloat naviBarHeight = self.navigationController.navigationBar.tz_height;
if (self.navigationController.navigationBar.isTranslucent) {
top = naviBarHeight;
if (iOS7Later && !TZ_isGlobalHideStatusBar) top += 20;
tableViewHeight = self.view.tz_height - top;
} else {
CGFloat navigationHeight = naviBarHeight;
if (iOS7Later && !TZ_isGlobalHideStatusBar) navigationHeight += 20;
tableViewHeight = self.view.tz_height - navigationHeight;
}
_tableView.frame = CGRectMake(0, top, self.view.tz_width, tableViewHeight);
}
#pragma mark - UITableViewDataSource && Delegate
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
......
......@@ -22,7 +22,7 @@
self = [super initWithFrame:frame];
if (self) {
self.backgroundColor = [UIColor blackColor];
self.previewView = [[TZPhotoPreviewView alloc] initWithFrame:self.bounds];
self.previewView = [[TZPhotoPreviewView alloc] initWithFrame:CGRectZero];
__weak typeof(self) weakSelf = self;
[self.previewView setSingleTapGestureBlock:^{
if (weakSelf.singleTapGestureBlock) {
......@@ -58,6 +58,11 @@
_previewView.cropRect = cropRect;
}
- (void)layoutSubviews {
[super layoutSubviews];
self.previewView.frame = self.bounds;
}
@end
......@@ -71,7 +76,6 @@
self = [super initWithFrame:frame];
if (self) {
_scrollView = [[UIScrollView alloc] init];
_scrollView.frame = CGRectMake(10, 0, self.tz_width - 20, self.tz_height);
_scrollView.bouncesZoom = YES;
_scrollView.maximumZoomScale = 2.5;
_scrollView.minimumZoomScale = 1.0;
......@@ -111,10 +115,6 @@
- (void)configProgressView {
_progressView = [[TZProgressView alloc] init];
static CGFloat progressWH = 40;
CGFloat progressX = (self.tz_width - progressWH) / 2;
CGFloat progressY = (self.tz_height - progressWH) / 2;
_progressView.frame = CGRectMake(progressX, progressY, progressWH, progressWH);
_progressView.hidden = YES;
[self addSubview:_progressView];
}
......@@ -163,7 +163,7 @@
[self bringSubviewToFront:_progressView];
progress = progress > 0.02 ? progress : 0.02;
_progressView.progress = progress;
if (self.imageProgressUpdateBlock) {
if (self.imageProgressUpdateBlock && progress < 1) {
self.imageProgressUpdateBlock(progress);
}
......@@ -230,7 +230,7 @@
_scrollView.contentSize = CGSizeMake(newSizeW, newSizeH);
_scrollView.alwaysBounceVertical = YES;
// 2.让scrollView新增滑动区域(裁剪框左上角的图片部分)
if (contentHeightAdd > 0) {
if (contentHeightAdd > 0 || contentWidthAdd > 0) {
_scrollView.contentInset = UIEdgeInsetsMake(contentHeightAdd, _cropRect.origin.x, 0, 0);
} else {
_scrollView.contentInset = UIEdgeInsetsZero;
......@@ -238,6 +238,17 @@
}
}
- (void)layoutSubviews {
[super layoutSubviews];
_scrollView.frame = CGRectMake(10, 0, self.tz_width - 20, self.tz_height);
static CGFloat progressWH = 40;
CGFloat progressX = (self.tz_width - progressWH) / 2;
CGFloat progressY = (self.tz_height - progressWH) / 2;
_progressView.frame = CGRectMake(progressX, progressY, progressWH, progressWH);
[self recoverSubviews];
}
#pragma mark - UITapGestureRecognizer Event
- (void)doubleTap:(UITapGestureRecognizer *)tap {
......
......@@ -16,6 +16,7 @@
@interface TZVideoPlayerController () {
AVPlayer *_player;
AVPlayerLayer *_playerLayer;
UIButton *_playButton;
UIImage *_cover;
......@@ -60,9 +61,9 @@
[[TZImageManager manager] getVideoWithAsset:_model.asset completion:^(AVPlayerItem *playerItem, NSDictionary *info) {
dispatch_async(dispatch_get_main_queue(), ^{
_player = [AVPlayer playerWithPlayerItem:playerItem];
AVPlayerLayer *playerLayer = [AVPlayerLayer playerLayerWithPlayer:_player];
playerLayer.frame = self.view.bounds;
[self.view.layer addSublayer:playerLayer];
_playerLayer = [AVPlayerLayer playerLayerWithPlayer:_player];
_playerLayer.frame = self.view.bounds;
[self.view.layer addSublayer:_playerLayer];
[self addProgressObserver];
[self configPlayButton];
[self configBottomToolBar];
......@@ -86,7 +87,6 @@
- (void)configPlayButton {
_playButton = [UIButton buttonWithType:UIButtonTypeCustom];
_playButton.frame = CGRectMake(0, 64, self.view.tz_width, self.view.tz_height - 64 - 44);
[_playButton setImage:[UIImage imageNamedFromMyBundle:@"MMVideoPreviewPlay.png"] forState:UIControlStateNormal];
[_playButton setImage:[UIImage imageNamedFromMyBundle:@"MMVideoPreviewPlayHL.png"] forState:UIControlStateHighlighted];
[_playButton addTarget:self action:@selector(playButtonClick) forControlEvents:UIControlEventTouchUpInside];
......@@ -94,12 +94,11 @@
}
- (void)configBottomToolBar {
_toolBar = [[UIView alloc] initWithFrame:CGRectMake(0, self.view.tz_height - 44, self.view.tz_width, 44)];
_toolBar = [[UIView alloc] initWithFrame:CGRectZero];
CGFloat rgb = 34 / 255.0;
_toolBar.backgroundColor = [UIColor colorWithRed:rgb green:rgb blue:rgb alpha:0.7];
_doneButton = [UIButton buttonWithType:UIButtonTypeCustom];
_doneButton.frame = CGRectMake(self.view.tz_width - 44 - 12, 0, 44, 44);
_doneButton.titleLabel.font = [UIFont systemFontOfSize:16];
[_doneButton addTarget:self action:@selector(doneButtonClick) forControlEvents:UIControlEventTouchUpInside];
TZImagePickerController *tzImagePickerVc = (TZImagePickerController *)self.navigationController;
......@@ -114,6 +113,17 @@
[self.view addSubview:_toolBar];
}
#pragma mark - Layout
- (void)viewDidLayoutSubviews {
[super viewDidLayoutSubviews];
_playerLayer.frame = self.view.bounds;
_playButton.frame = CGRectMake(0, 64, self.view.tz_width, self.view.tz_height - 64 - 44);
_doneButton.frame = CGRectMake(self.view.tz_width - 44 - 12, 0, 44, 44);
_toolBar.frame = CGRectMake(0, self.view.tz_height - 44, self.view.tz_width, 44);
}
#pragma mark - Click Event
- (void)playButtonClick {
......
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