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

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

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