18
18
#import " TZLocationManager.h"
19
19
#import < MobileCoreServices/MobileCoreServices.h>
20
20
#import " TZImageRequestOperation.h"
21
- #import " TZTipShowFooterView .h"
21
+ #import " TZAuthLimitedFooterTipView .h"
22
22
#import < PhotosUI/PhotosUI.h>
23
23
@interface TZPhotoPickerController ()<UICollectionViewDataSource,UICollectionViewDelegate,UIImagePickerControllerDelegate,UINavigationControllerDelegate, PHPhotoLibraryChangeObserver> {
24
24
NSMutableArray *_models;
@@ -34,14 +34,14 @@ @interface TZPhotoPickerController ()<UICollectionViewDataSource,UICollectionVie
34
34
35
35
BOOL _shouldScrollToBottom;
36
36
BOOL _showTakePhotoBtn;
37
- BOOL _authorizationStatusLimited ;
37
+ BOOL _authorizationLimited ;
38
38
39
39
CGFloat _offsetItemCount;
40
40
}
41
41
@property CGRect previousPreheatRect;
42
42
@property (nonatomic , assign ) BOOL isSelectOriginalPhoto;
43
43
@property (nonatomic , strong ) TZCollectionView *collectionView;
44
- @property (nonatomic ,strong ) TZTipShowFooterView *footerTipView; // 底部提示
44
+ @property (nonatomic , strong ) TZAuthLimitedFooterTipView *authFooterTipView;
45
45
@property (nonatomic , strong ) UILabel *noDataLabel;
46
46
@property (strong , nonatomic ) UICollectionViewFlowLayout *layout;
47
47
@property (nonatomic , strong ) UIImagePickerController *imagePickerVc;
@@ -110,7 +110,7 @@ - (void)viewDidLoad {
110
110
[tzImagePickerVc.childViewControllers firstObject ].navigationItem .backBarButtonItem = backItem;
111
111
}
112
112
_showTakePhotoBtn = _model.isCameraRoll && ((tzImagePickerVc.allowTakePicture && tzImagePickerVc.allowPickingImage ) || (tzImagePickerVc.allowTakeVideo && tzImagePickerVc.allowPickingVideo ));
113
- _authorizationStatusLimited = [[TZImageManager manager ] isPHAuthorizationStatusLimited ];
113
+ _authorizationLimited = [[TZImageManager manager ] isPHAuthorizationStatusLimited ];
114
114
// [self resetCachedAssets];
115
115
[[NSNotificationCenter defaultCenter ] addObserver: self selector: @selector (didChangeStatusBarOrientationNotification: ) name: UIApplicationDidChangeStatusBarOrientationNotification object: nil ];
116
116
@@ -195,29 +195,25 @@ - (void)configCollectionView {
195
195
[_collectionView reloadData ];
196
196
}
197
197
198
- if (!_footerTipView && _authorizationStatusLimited ) {
199
- _footerTipView = [[TZTipShowFooterView alloc ] initWithFrame: CGRectMake (0 , 0 , self .view.tz_width, 80 )];
198
+ if (!_authFooterTipView && _authorizationLimited ) {
199
+ _authFooterTipView = [[TZAuthLimitedFooterTipView alloc ] initWithFrame: CGRectMake (0 , 0 , self .view.tz_width, 80 )];
200
200
UITapGestureRecognizer *footTap = [[UITapGestureRecognizer alloc ] initWithTarget: self action: @selector (openSettingsApplication )];
201
- [_footerTipView addGestureRecognizer: footTap];
202
- [self .view addSubview: _footerTipView ];
201
+ [_authFooterTipView addGestureRecognizer: footTap];
202
+ [self .view addSubview: _authFooterTipView ];
203
203
}
204
204
205
- if (_showTakePhotoBtn) {
206
- _collectionView.contentSize = CGSizeMake (self.view .tz_width , ((_model.count + self.columnNumber ) / self.columnNumber ) * self.view .tz_width );
207
- } else {
208
- _collectionView.contentSize = CGSizeMake (self.view .tz_width , ((_model.count + self.columnNumber - 1 ) / self.columnNumber ) * self.view .tz_width );
209
- if (_models.count == 0 ) {
210
- _noDataLabel = [UILabel new ];
211
- _noDataLabel.textAlignment = NSTextAlignmentCenter;
212
- _noDataLabel.text = [NSBundle tz_localizedStringForKey: @" No Photos or Videos" ];
213
- CGFloat rgb = 153 / 256.0 ;
214
- _noDataLabel.textColor = [UIColor colorWithRed: rgb green: rgb blue: rgb alpha: 1.0 ];
215
- _noDataLabel.font = [UIFont boldSystemFontOfSize: 20 ];
216
- [_collectionView addSubview: _noDataLabel];
217
- } else if (_noDataLabel) {
218
- [_noDataLabel removeFromSuperview ];
219
- _noDataLabel = nil ;
220
- }
205
+ _collectionView.contentSize = CGSizeMake (self.view .tz_width , (([self getAllCellCount ] + self.columnNumber - 1 ) / self.columnNumber ) * self.view .tz_width );
206
+ if (_models.count == 0 ) {
207
+ _noDataLabel = [UILabel new ];
208
+ _noDataLabel.textAlignment = NSTextAlignmentCenter;
209
+ _noDataLabel.text = [NSBundle tz_localizedStringForKey: @" No Photos or Videos" ];
210
+ CGFloat rgb = 153 / 256.0 ;
211
+ _noDataLabel.textColor = [UIColor colorWithRed: rgb green: rgb blue: rgb alpha: 1.0 ];
212
+ _noDataLabel.font = [UIFont boldSystemFontOfSize: 20 ];
213
+ [_collectionView addSubview: _noDataLabel];
214
+ } else if (_noDataLabel) {
215
+ [_noDataLabel removeFromSuperview ];
216
+ _noDataLabel = nil ;
221
217
}
222
218
}
223
219
@@ -367,6 +363,7 @@ - (void)viewDidLayoutSubviews {
367
363
CGFloat top = 0 ;
368
364
CGFloat collectionViewHeight = 0 ;
369
365
CGFloat naviBarHeight = self.navigationController .navigationBar .tz_height ;
366
+ CGFloat footerTipViewH = _authorizationLimited ? 80 : 0 ;
370
367
BOOL isStatusBarHidden = [UIApplication sharedApplication ].isStatusBarHidden ;
371
368
BOOL isFullScreen = self.view .tz_height == [UIScreen mainScreen ].bounds .size .height ;
372
369
CGFloat toolBarHeight = 50 + [TZCommonTools tz_safeAreaInsets ].bottom ;
@@ -377,9 +374,9 @@ - (void)viewDidLayoutSubviews {
377
374
} else {
378
375
collectionViewHeight = tzImagePickerVc.showSelectBtn ? self.view .tz_height - toolBarHeight : self.view .tz_height ;
379
376
}
377
+ collectionViewHeight -= footerTipViewH;
380
378
381
- CGFloat tipViewH = _authorizationStatusLimited ? 80 : 0 ;
382
- _collectionView.frame = CGRectMake (0 , top, self.view .tz_width , collectionViewHeight - tipViewH);
379
+ _collectionView.frame = CGRectMake (0 , top, self.view .tz_width , collectionViewHeight);
383
380
_noDataLabel.frame = _collectionView.bounds ;
384
381
CGFloat itemWH = (self.view .tz_width - (self.columnNumber + 1 ) * itemMargin) / self.columnNumber ;
385
382
_layout.itemSize = CGSizeMake (itemWH, itemWH);
@@ -399,13 +396,9 @@ - (void)viewDidLayoutSubviews {
399
396
toolBarTop = self.view .tz_height - toolBarHeight - navigationHeight;
400
397
}
401
398
_bottomToolBar.frame = CGRectMake (0 , toolBarTop, self.view .tz_width , toolBarHeight);
402
- if (_authorizationStatusLimited) {
403
- CGFloat tipY = toolBarTop - tipViewH;
404
- CGRect tipRect = CGRectMake (0 , self.view .tz_height - tipViewH, self.view .tz_width , tipViewH);;
405
- if (_bottomToolBar) {
406
- tipRect = CGRectMake (0 , tipY, self.view .tz_width , tipViewH);
407
- }
408
- _footerTipView.frame = tipRect;
399
+ if (_authFooterTipView) {
400
+ CGFloat footerTipViewY = _bottomToolBar ? toolBarTop - footerTipViewH : self.view .tz_height - footerTipViewH;
401
+ _authFooterTipView.frame = CGRectMake (0 , footerTipViewY, self.view .tz_width , footerTipViewH);;
409
402
}
410
403
CGFloat previewWidth = [tzImagePickerVc.previewBtnTitleStr boundingRectWithSize: CGSizeMake (CGFLOAT_MAX, CGFLOAT_MAX) options: NSStringDrawingUsesFontLeading attributes: @{NSFontAttributeName :[UIFont systemFontOfSize: 16 ]} context: nil ].size .width + 2 ;
411
404
if (!tzImagePickerVc.allowPreview ) {
@@ -584,7 +577,7 @@ - (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cell
584
577
// the cell lead to add more photo / 去添加更多照片的cell
585
578
if (indexPath.item == [self getAddMorePhotoCellIndex ]) {
586
579
TZAssetCameraCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier: @" TZAssetCameraCell" forIndexPath: indexPath];
587
- cell.imageView .image = tzImagePickerVc.xy_addMoreLimitImage ;
580
+ cell.imageView .image = tzImagePickerVc.addMorePhotoImage ;
588
581
cell.imageView .contentMode = UIViewContentModeScaleAspectFit;
589
582
cell.imageView .backgroundColor = [UIColor colorWithWhite: 1.000 alpha: 0.500 ];
590
583
return cell;
@@ -751,7 +744,7 @@ - (NSInteger)getAllCellCount {
751
744
if (_showTakePhotoBtn) {
752
745
count += 1 ;
753
746
}
754
- if (_authorizationStatusLimited ) {
747
+ if (_authorizationLimited ) {
755
748
count += 1 ;
756
749
}
757
750
return count;
@@ -771,7 +764,7 @@ - (NSInteger)getTakePhotoCellIndex {
771
764
772
765
- (NSInteger )getAddMorePhotoCellIndex {
773
766
TZImagePickerController *tzImagePickerVc = (TZImagePickerController *)self.navigationController ;
774
- if (!_authorizationStatusLimited ) {
767
+ if (!_authorizationLimited ) {
775
768
return -1 ;
776
769
}
777
770
if (tzImagePickerVc.sortAscendingByModificationDate ) {
0 commit comments