TZPhotoPreviewController.m 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433
  1. //
  2. // TZPhotoPreviewController.m
  3. // TZImagePickerController
  4. //
  5. // Created by 谭真 on 15/12/24.
  6. // Copyright © 2015年 谭真. All rights reserved.
  7. //
  8. #import "TZPhotoPreviewController.h"
  9. #import "TZPhotoPreviewCell.h"
  10. #import "TZAssetModel.h"
  11. #import "UIView+Layout.h"
  12. #import "TZImagePickerController.h"
  13. #import "TZImageManager.h"
  14. #import "TZImageCropManager.h"
  15. @interface TZPhotoPreviewController ()<UICollectionViewDataSource,UICollectionViewDelegate,UIScrollViewDelegate> {
  16. UICollectionView *_collectionView;
  17. NSArray *_photosTemp;
  18. NSArray *_assetsTemp;
  19. UIView *_naviBar;
  20. UIButton *_backButton;
  21. UIButton *_selectButton;
  22. UIView *_toolBar;
  23. UIButton *_doneButton;
  24. UIImageView *_numberImageView;
  25. UILabel *_numberLabel;
  26. UIButton *_originalPhotoButton;
  27. UILabel *_originalPhotoLabel;
  28. }
  29. @property (nonatomic, assign) BOOL isHideNaviBar;
  30. @property (nonatomic, strong) UIView *cropBgView;
  31. @property (nonatomic, strong) UIView *cropView;
  32. @property (nonatomic, assign) double progress;
  33. @end
  34. @implementation TZPhotoPreviewController
  35. - (void)viewDidLoad {
  36. [super viewDidLoad];
  37. [TZImageManager manager].shouldFixOrientation = YES;
  38. __weak typeof(self) weakSelf = self;
  39. TZImagePickerController *_tzImagePickerVc = (TZImagePickerController *)weakSelf.navigationController;
  40. if (!self.models.count) {
  41. self.models = [NSMutableArray arrayWithArray:_tzImagePickerVc.selectedModels];
  42. _assetsTemp = [NSMutableArray arrayWithArray:_tzImagePickerVc.selectedAssets];
  43. self.isSelectOriginalPhoto = _tzImagePickerVc.isSelectOriginalPhoto;
  44. }
  45. [self configCollectionView];
  46. [self configCropView];
  47. [self configCustomNaviBar];
  48. [self configBottomToolBar];
  49. self.view.clipsToBounds = YES;
  50. }
  51. - (void)setPhotos:(NSMutableArray *)photos {
  52. _photos = photos;
  53. _photosTemp = [NSArray arrayWithArray:photos];
  54. }
  55. - (void)viewWillAppear:(BOOL)animated {
  56. [super viewWillAppear:animated];
  57. [self.navigationController setNavigationBarHidden:YES];
  58. if (iOS7Later) [UIApplication sharedApplication].statusBarHidden = YES;
  59. if (_currentIndex) [_collectionView setContentOffset:CGPointMake((self.view.tz_width + 20) * _currentIndex, 0) animated:NO];
  60. [self refreshNaviBarAndBottomBarState];
  61. }
  62. - (void)viewWillDisappear:(BOOL)animated {
  63. [super viewWillDisappear:animated];
  64. [self.navigationController setNavigationBarHidden:NO];
  65. if (iOS7Later) [UIApplication sharedApplication].statusBarHidden = NO;
  66. [TZImageManager manager].shouldFixOrientation = NO;
  67. }
  68. - (BOOL)prefersStatusBarHidden {
  69. return YES;
  70. }
  71. - (void)configCustomNaviBar {
  72. TZImagePickerController *tzImagePickerVc = (TZImagePickerController *)self.navigationController;
  73. _naviBar = [[UIView alloc] initWithFrame:CGRectMake(0, 0, self.view.tz_width, 64)];
  74. _naviBar.backgroundColor = [UIColor colorWithRed:(34/255.0) green:(34/255.0) blue:(34/255.0) alpha:0.7];
  75. _backButton = [[UIButton alloc] initWithFrame:CGRectMake(10, 10, 44, 44)];
  76. [_backButton setImage:[UIImage imageNamedFromMyBundle:@"navi_back.png"] forState:UIControlStateNormal];
  77. [_backButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
  78. [_backButton addTarget:self action:@selector(backButtonClick) forControlEvents:UIControlEventTouchUpInside];
  79. _selectButton = [[UIButton alloc] initWithFrame:CGRectMake(self.view.tz_width - 54, 10, 42, 42)];
  80. [_selectButton setImage:[UIImage imageNamedFromMyBundle:tzImagePickerVc.photoDefImageName] forState:UIControlStateNormal];
  81. [_selectButton setImage:[UIImage imageNamedFromMyBundle:tzImagePickerVc.photoSelImageName] forState:UIControlStateSelected];
  82. [_selectButton addTarget:self action:@selector(select:) forControlEvents:UIControlEventTouchUpInside];
  83. _selectButton.hidden = !tzImagePickerVc.showSelectBtn;
  84. [_naviBar addSubview:_selectButton];
  85. [_naviBar addSubview:_backButton];
  86. [self.view addSubview:_naviBar];
  87. }
  88. - (void)configBottomToolBar {
  89. _toolBar = [[UIView alloc] initWithFrame:CGRectMake(0, self.view.tz_height - 44, self.view.tz_width, 44)];
  90. static CGFloat rgb = 34 / 255.0;
  91. _toolBar.backgroundColor = [UIColor colorWithRed:rgb green:rgb blue:rgb alpha:0.7];
  92. TZImagePickerController *_tzImagePickerVc = (TZImagePickerController *)self.navigationController;
  93. if (_tzImagePickerVc.allowPickingOriginalPhoto) {
  94. CGFloat fullImageWidth = [_tzImagePickerVc.fullImageBtnTitleStr boundingRectWithSize:CGSizeMake(CGFLOAT_MAX, CGFLOAT_MAX) options:NSStringDrawingUsesFontLeading attributes:@{NSFontAttributeName:[UIFont systemFontOfSize:13]} context:nil].size.width;
  95. _originalPhotoButton = [UIButton buttonWithType:UIButtonTypeCustom];
  96. _originalPhotoButton.frame = CGRectMake(0, 0, fullImageWidth + 56, 44);
  97. _originalPhotoButton.imageEdgeInsets = UIEdgeInsetsMake(0, -10, 0, 0);
  98. _originalPhotoButton.backgroundColor = [UIColor clearColor];
  99. [_originalPhotoButton addTarget:self action:@selector(originalPhotoButtonClick) forControlEvents:UIControlEventTouchUpInside];
  100. _originalPhotoButton.titleLabel.font = [UIFont systemFontOfSize:13];
  101. [_originalPhotoButton setTitle:_tzImagePickerVc.fullImageBtnTitleStr forState:UIControlStateNormal];
  102. [_originalPhotoButton setTitle:_tzImagePickerVc.fullImageBtnTitleStr forState:UIControlStateSelected];
  103. [_originalPhotoButton setTitleColor:[UIColor lightGrayColor] forState:UIControlStateNormal];
  104. [_originalPhotoButton setTitleColor:[UIColor whiteColor] forState:UIControlStateSelected];
  105. [_originalPhotoButton setImage:[UIImage imageNamedFromMyBundle:_tzImagePickerVc.photoPreviewOriginDefImageName] forState:UIControlStateNormal];
  106. [_originalPhotoButton setImage:[UIImage imageNamedFromMyBundle:_tzImagePickerVc.photoOriginSelImageName] forState:UIControlStateSelected];
  107. _originalPhotoLabel = [[UILabel alloc] init];
  108. _originalPhotoLabel.frame = CGRectMake(fullImageWidth + 42, 0, 80, 44);
  109. _originalPhotoLabel.textAlignment = NSTextAlignmentLeft;
  110. _originalPhotoLabel.font = [UIFont systemFontOfSize:13];
  111. _originalPhotoLabel.textColor = [UIColor whiteColor];
  112. _originalPhotoLabel.backgroundColor = [UIColor clearColor];
  113. if (_isSelectOriginalPhoto) [self showPhotoBytes];
  114. }
  115. _doneButton = [UIButton buttonWithType:UIButtonTypeCustom];
  116. _doneButton.frame = CGRectMake(self.view.tz_width - 44 - 12, 0, 44, 44);
  117. _doneButton.titleLabel.font = [UIFont systemFontOfSize:16];
  118. [_doneButton addTarget:self action:@selector(doneButtonClick) forControlEvents:UIControlEventTouchUpInside];
  119. [_doneButton setTitle:_tzImagePickerVc.doneBtnTitleStr forState:UIControlStateNormal];
  120. [_doneButton setTitleColor:_tzImagePickerVc.oKButtonTitleColorNormal forState:UIControlStateNormal];
  121. _numberImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamedFromMyBundle:_tzImagePickerVc.photoNumberIconImageName]];
  122. _numberImageView.backgroundColor = [UIColor clearColor];
  123. _numberImageView.frame = CGRectMake(self.view.tz_width - 56 - 28, 7, 30, 30);
  124. _numberImageView.hidden = _tzImagePickerVc.selectedModels.count <= 0;
  125. _numberLabel = [[UILabel alloc] init];
  126. _numberLabel.frame = _numberImageView.frame;
  127. _numberLabel.font = [UIFont systemFontOfSize:15];
  128. _numberLabel.textColor = [UIColor whiteColor];
  129. _numberLabel.textAlignment = NSTextAlignmentCenter;
  130. _numberLabel.text = [NSString stringWithFormat:@"%zd",_tzImagePickerVc.selectedModels.count];
  131. _numberLabel.hidden = _tzImagePickerVc.selectedModels.count <= 0;
  132. _numberLabel.backgroundColor = [UIColor clearColor];
  133. [_originalPhotoButton addSubview:_originalPhotoLabel];
  134. [_toolBar addSubview:_doneButton];
  135. [_toolBar addSubview:_originalPhotoButton];
  136. [_toolBar addSubview:_numberImageView];
  137. [_toolBar addSubview:_numberLabel];
  138. [self.view addSubview:_toolBar];
  139. }
  140. - (void)configCollectionView {
  141. UICollectionViewFlowLayout *layout = [[UICollectionViewFlowLayout alloc] init];
  142. layout.scrollDirection = UICollectionViewScrollDirectionHorizontal;
  143. layout.itemSize = CGSizeMake(self.view.tz_width + 20, self.view.tz_height);
  144. layout.minimumInteritemSpacing = 0;
  145. layout.minimumLineSpacing = 0;
  146. _collectionView = [[UICollectionView alloc] initWithFrame:CGRectMake(-10, 0, self.view.tz_width + 20, self.view.tz_height) collectionViewLayout:layout];
  147. _collectionView.backgroundColor = [UIColor blackColor];
  148. _collectionView.dataSource = self;
  149. _collectionView.delegate = self;
  150. _collectionView.pagingEnabled = YES;
  151. _collectionView.scrollsToTop = NO;
  152. _collectionView.showsHorizontalScrollIndicator = NO;
  153. _collectionView.contentOffset = CGPointMake(0, 0);
  154. _collectionView.contentSize = CGSizeMake(self.models.count * (self.view.tz_width + 20), 0);
  155. [self.view addSubview:_collectionView];
  156. [_collectionView registerClass:[TZPhotoPreviewCell class] forCellWithReuseIdentifier:@"TZPhotoPreviewCell"];
  157. }
  158. - (void)configCropView {
  159. TZImagePickerController *_tzImagePickerVc = (TZImagePickerController *)self.navigationController;
  160. if (!_tzImagePickerVc.showSelectBtn && _tzImagePickerVc.allowCrop) {
  161. _cropBgView = [UIView new];
  162. _cropBgView.userInteractionEnabled = NO;
  163. _cropBgView.backgroundColor = [UIColor clearColor];
  164. _cropBgView.frame = self.view.bounds;
  165. [self.view addSubview:_cropBgView];
  166. [TZImageCropManager overlayClippingWithView:_cropBgView cropRect:_tzImagePickerVc.cropRect containerView:self.view needCircleCrop:_tzImagePickerVc.needCircleCrop];
  167. _cropView = [UIView new];
  168. _cropView.userInteractionEnabled = NO;
  169. _cropView.backgroundColor = [UIColor clearColor];
  170. _cropView.frame = _tzImagePickerVc.cropRect;
  171. _cropView.layer.borderColor = [UIColor whiteColor].CGColor;
  172. _cropView.layer.borderWidth = 1.0;
  173. if (_tzImagePickerVc.needCircleCrop) {
  174. _cropView.layer.cornerRadius = _tzImagePickerVc.cropRect.size.width / 2;
  175. _cropView.clipsToBounds = YES;
  176. }
  177. [self.view addSubview:_cropView];
  178. if (_tzImagePickerVc.cropViewSettingBlock) {
  179. _tzImagePickerVc.cropViewSettingBlock(_cropView);
  180. }
  181. }
  182. }
  183. #pragma mark - Click Event
  184. - (void)select:(UIButton *)selectButton {
  185. TZImagePickerController *_tzImagePickerVc = (TZImagePickerController *)self.navigationController;
  186. TZAssetModel *model = _models[_currentIndex];
  187. if (!selectButton.isSelected) {
  188. // 1. select:check if over the maxImagesCount / 选择照片,检查是否超过了最大个数的限制
  189. if (_tzImagePickerVc.selectedModels.count >= _tzImagePickerVc.maxImagesCount) {
  190. NSString *title = [NSString stringWithFormat:[NSBundle tz_localizedStringForKey:@"Select a maximum of %zd photos"], _tzImagePickerVc.maxImagesCount];
  191. [_tzImagePickerVc showAlertWithTitle:title];
  192. return;
  193. // 2. if not over the maxImagesCount / 如果没有超过最大个数限制
  194. } else {
  195. [_tzImagePickerVc.selectedModels addObject:model];
  196. if (self.photos) {
  197. [_tzImagePickerVc.selectedAssets addObject:_assetsTemp[_currentIndex]];
  198. [self.photos addObject:_photosTemp[_currentIndex]];
  199. }
  200. if (model.type == TZAssetModelMediaTypeVideo) {
  201. [_tzImagePickerVc showAlertWithTitle:[NSBundle tz_localizedStringForKey:@"Select the video when in multi state, we will handle the video as a photo"]];
  202. }
  203. }
  204. } else {
  205. NSArray *selectedModels = [NSArray arrayWithArray:_tzImagePickerVc.selectedModels];
  206. for (TZAssetModel *model_item in selectedModels) {
  207. if ([[[TZImageManager manager] getAssetIdentifier:model.asset] isEqualToString:[[TZImageManager manager] getAssetIdentifier:model_item.asset]]) {
  208. // 1.6.7版本更新:防止有多个一样的model,一次性被移除了
  209. NSArray *selectedModelsTmp = [NSArray arrayWithArray:_tzImagePickerVc.selectedModels];
  210. for (NSInteger i = 0; i < selectedModelsTmp.count; i++) {
  211. TZAssetModel *model = selectedModelsTmp[i];
  212. if ([model isEqual:model_item]) {
  213. [_tzImagePickerVc.selectedModels removeObjectAtIndex:i];
  214. break;
  215. }
  216. }
  217. // [_tzImagePickerVc.selectedModels removeObject:model_item];
  218. if (self.photos) {
  219. // 1.6.7版本更新:防止有多个一样的asset,一次性被移除了
  220. NSArray *selectedAssetsTmp = [NSArray arrayWithArray:_tzImagePickerVc.selectedAssets];
  221. for (NSInteger i = 0; i < selectedAssetsTmp.count; i++) {
  222. id asset = selectedAssetsTmp[i];
  223. if ([asset isEqual:_assetsTemp[_currentIndex]]) {
  224. [_tzImagePickerVc.selectedAssets removeObjectAtIndex:i];
  225. break;
  226. }
  227. }
  228. // [_tzImagePickerVc.selectedAssets removeObject:_assetsTemp[_currentIndex]];
  229. [self.photos removeObject:_photosTemp[_currentIndex]];
  230. }
  231. break;
  232. }
  233. }
  234. }
  235. model.isSelected = !selectButton.isSelected;
  236. [self refreshNaviBarAndBottomBarState];
  237. if (model.isSelected) {
  238. [UIView showOscillatoryAnimationWithLayer:selectButton.imageView.layer type:TZOscillatoryAnimationToBigger];
  239. }
  240. [UIView showOscillatoryAnimationWithLayer:_numberImageView.layer type:TZOscillatoryAnimationToSmaller];
  241. }
  242. - (void)backButtonClick {
  243. if (self.navigationController.childViewControllers.count < 2) {
  244. [self.navigationController dismissViewControllerAnimated:YES completion:nil];
  245. return;
  246. }
  247. [self.navigationController popViewControllerAnimated:YES];
  248. if (self.backButtonClickBlock) {
  249. self.backButtonClickBlock(_isSelectOriginalPhoto);
  250. }
  251. }
  252. - (void)doneButtonClick {
  253. TZImagePickerController *_tzImagePickerVc = (TZImagePickerController *)self.navigationController;
  254. // 如果图片正在从iCloud同步中,提醒用户
  255. if (_progress > 0 && _progress < 1) {
  256. [_tzImagePickerVc showAlertWithTitle:[NSBundle tz_localizedStringForKey:@"Synchronizing photos from iCloud"]]; return;
  257. }
  258. // 如果没有选中过照片 点击确定时选中当前预览的照片
  259. if (_tzImagePickerVc.selectedModels.count == 0 && _tzImagePickerVc.minImagesCount <= 0) {
  260. TZAssetModel *model = _models[_currentIndex];
  261. [_tzImagePickerVc.selectedModels addObject:model];
  262. }
  263. if (_tzImagePickerVc.allowCrop) { // 裁剪状态
  264. NSIndexPath *indexPath = [NSIndexPath indexPathForItem:_currentIndex inSection:0];
  265. TZPhotoPreviewCell *cell = (TZPhotoPreviewCell *)[_collectionView cellForItemAtIndexPath:indexPath];
  266. UIImage *cropedImage = [TZImageCropManager cropImageView:cell.previewView.imageView toRect:_tzImagePickerVc.cropRect zoomScale:cell.previewView.scrollView.zoomScale containerView:self.view];
  267. if (_tzImagePickerVc.needCircleCrop) {
  268. cropedImage = [TZImageCropManager circularClipImage:cropedImage];
  269. }
  270. if (self.doneButtonClickBlockCropMode) {
  271. TZAssetModel *model = _models[_currentIndex];
  272. self.doneButtonClickBlockCropMode(cropedImage,model.asset);
  273. }
  274. } else if (self.doneButtonClickBlock) { // 非裁剪状态
  275. self.doneButtonClickBlock(_isSelectOriginalPhoto);
  276. }
  277. if (self.doneButtonClickBlockWithPreviewType) {
  278. self.doneButtonClickBlockWithPreviewType(self.photos,_tzImagePickerVc.selectedAssets,self.isSelectOriginalPhoto);
  279. }
  280. }
  281. - (void)originalPhotoButtonClick {
  282. _originalPhotoButton.selected = !_originalPhotoButton.isSelected;
  283. _isSelectOriginalPhoto = _originalPhotoButton.isSelected;
  284. _originalPhotoLabel.hidden = !_originalPhotoButton.isSelected;
  285. if (_isSelectOriginalPhoto) {
  286. [self showPhotoBytes];
  287. if (!_selectButton.isSelected) {
  288. // 如果当前已选择照片张数 < 最大可选张数 && 最大可选张数大于1,就选中该张图
  289. TZImagePickerController *_tzImagePickerVc = (TZImagePickerController *)self.navigationController;
  290. if (_tzImagePickerVc.selectedModels.count < _tzImagePickerVc.maxImagesCount && _tzImagePickerVc.showSelectBtn) {
  291. [self select:_selectButton];
  292. }
  293. }
  294. }
  295. }
  296. #pragma mark - UIScrollViewDelegate
  297. - (void)scrollViewDidScroll:(UIScrollView *)scrollView {
  298. CGFloat offSetWidth = scrollView.contentOffset.x;
  299. offSetWidth = offSetWidth + ((self.view.tz_width + 20) * 0.5);
  300. NSInteger currentIndex = offSetWidth / (self.view.tz_width + 20);
  301. if (currentIndex < _models.count && _currentIndex != currentIndex) {
  302. _currentIndex = currentIndex;
  303. [self refreshNaviBarAndBottomBarState];
  304. }
  305. }
  306. #pragma mark - UICollectionViewDataSource && Delegate
  307. - (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section {
  308. return _models.count;
  309. }
  310. - (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {
  311. TZPhotoPreviewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"TZPhotoPreviewCell" forIndexPath:indexPath];
  312. cell.model = _models[indexPath.row];
  313. TZImagePickerController *_tzImagePickerVc = (TZImagePickerController *)self.navigationController;
  314. cell.cropRect = _tzImagePickerVc.cropRect;
  315. cell.allowCrop = _tzImagePickerVc.allowCrop;
  316. __weak typeof(self) weakSelf = self;
  317. if (!cell.singleTapGestureBlock) {
  318. __weak typeof(_naviBar) weakNaviBar = _naviBar;
  319. __weak typeof(_toolBar) weakToolBar = _toolBar;
  320. cell.singleTapGestureBlock = ^(){
  321. // show or hide naviBar / 显示或隐藏导航栏
  322. weakSelf.isHideNaviBar = !weakSelf.isHideNaviBar;
  323. weakNaviBar.hidden = weakSelf.isHideNaviBar;
  324. weakToolBar.hidden = weakSelf.isHideNaviBar;
  325. };
  326. }
  327. [cell setImageProgressUpdateBlock:^(double progress) {
  328. weakSelf.progress = progress;
  329. }];
  330. return cell;
  331. }
  332. - (void)collectionView:(UICollectionView *)collectionView willDisplayCell:(UICollectionViewCell *)cell forItemAtIndexPath:(NSIndexPath *)indexPath {
  333. if ([cell isKindOfClass:[TZPhotoPreviewCell class]]) {
  334. [(TZPhotoPreviewCell *)cell recoverSubviews];
  335. }
  336. }
  337. - (void)collectionView:(UICollectionView *)collectionView didEndDisplayingCell:(UICollectionViewCell *)cell forItemAtIndexPath:(NSIndexPath *)indexPath {
  338. if ([cell isKindOfClass:[TZPhotoPreviewCell class]]) {
  339. [(TZPhotoPreviewCell *)cell recoverSubviews];
  340. }
  341. }
  342. #pragma mark - Private Method
  343. - (void)dealloc {
  344. //NSLog(@"TZPhotoPreviewController dealloc");
  345. }
  346. - (void)refreshNaviBarAndBottomBarState {
  347. TZImagePickerController *_tzImagePickerVc = (TZImagePickerController *)self.navigationController;
  348. TZAssetModel *model = _models[_currentIndex];
  349. _selectButton.selected = model.isSelected;
  350. _numberLabel.text = [NSString stringWithFormat:@"%zd",_tzImagePickerVc.selectedModels.count];
  351. _numberImageView.hidden = (_tzImagePickerVc.selectedModels.count <= 0 || _isHideNaviBar || _isCropImage);
  352. _numberLabel.hidden = (_tzImagePickerVc.selectedModels.count <= 0 || _isHideNaviBar || _isCropImage);
  353. _originalPhotoButton.selected = _isSelectOriginalPhoto;
  354. _originalPhotoLabel.hidden = !_originalPhotoButton.isSelected;
  355. if (_isSelectOriginalPhoto) [self showPhotoBytes];
  356. // If is previewing video, hide original photo button
  357. // 如果正在预览的是视频,隐藏原图按钮
  358. if (!_isHideNaviBar) {
  359. if (model.type == TZAssetModelMediaTypeVideo) {
  360. _originalPhotoButton.hidden = YES;
  361. _originalPhotoLabel.hidden = YES;
  362. } else {
  363. _originalPhotoButton.hidden = NO;
  364. if (_isSelectOriginalPhoto) _originalPhotoLabel.hidden = NO;
  365. }
  366. }
  367. _doneButton.hidden = NO;
  368. _selectButton.hidden = !_tzImagePickerVc.showSelectBtn;
  369. // 让宽度/高度小于 最小可选照片尺寸 的图片不能选中
  370. if (![[TZImageManager manager] isPhotoSelectableWithAsset:model.asset]) {
  371. _numberLabel.hidden = YES;
  372. _numberImageView.hidden = YES;
  373. _selectButton.hidden = YES;
  374. _originalPhotoButton.hidden = YES;
  375. _originalPhotoLabel.hidden = YES;
  376. _doneButton.hidden = YES;
  377. }
  378. }
  379. - (void)showPhotoBytes {
  380. [[TZImageManager manager] getPhotosBytesWithArray:@[_models[_currentIndex]] completion:^(NSString *totalBytes) {
  381. _originalPhotoLabel.text = [NSString stringWithFormat:@"(%@)",totalBytes];
  382. }];
  383. }
  384. @end