// // uploadImageOrVideoViewController.m // 隐私保护 // // Created by xd h on 2023/11/9. // #import "uploadImageOrVideoViewController.h" #import #import #import "AJPhotoListView.h" #import "AJPhotoGroupView.h" #import "AJPhotoListCell.h" #import "uploadFileBottomView.h" #import "PhotoPreviewViewController.h" #import "TZAssetModel+imageData.h" #import "uploadFileRecordViewController.h" #import "couldPhoneBaseInfoModel.h" #import "fileTransferPathCheckViewController.h" #import "ComontAlretViewController.h" @interface uploadImageOrVideoViewController () { couldPhoneBaseInfoModel *baseInfoModel; BOOL isNotPhotoPermission;//没有权限 } @property (strong, nonatomic) AJPhotoGroupView *photoGroupView; @property (strong, nonatomic) UILabel *MytitleLabel; @property (strong, nonatomic) UIImageView *selectTip; @property (nonatomic,assign) BOOL isNotAllowed; @property (strong, nonatomic) UIView *bgMaskView; @property (strong, nonatomic) AJPhotoListView *photoListView; @property (strong, nonatomic) NSMutableArray *assets; @property (strong, nonatomic) NSIndexPath *lastAccessed; @property (strong, nonatomic) uploadFileBottomView *uploadFileBottomV; //最多选择项 //@property (nonatomic, assign) NSInteger maximumNumberOfSelection; //最少选择项 @property (nonatomic, assign) NSInteger minimumNumberOfSelection; //是否开启多选 @property (nonatomic, assign) BOOL multipleSelection; @property (nonatomic,assign) BOOL isNotFirstType; @end @implementation uploadImageOrVideoViewController - (void)viewDidLoad { [super viewDidLoad]; // Do any additional setup after loading the view. //[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(getCouldPhoneBaseInfoFun:) name:getCouldPhoneBaseInfoNotification object:nil]; [self.view setBackgroundColor:HWF5F7FAColor]; [self.toolBar setHidden:YES]; [self.navigationBar setHidden:YES]; [self.navBarBGView setHidden:NO]; [self initBaselUIFun]; _isNotAllowed = YES; //_maximumNumberOfSelection = 3; _minimumNumberOfSelection = 0; _multipleSelection = YES; if(!_selectionFilter) { _selectionFilter = [NSPredicate predicateWithValue:YES]; } [self checkVideoAccessFun]; [[webRtcManager shareManager] getBaseInfoFun]; } - (void)initBaselUIFun { [self initNavHeadUIFun]; //列表view [self setupPhotoListView]; [self setupUploadFileBottomView]; //相册分组 [self setupGroupView]; } - (void)initNavHeadUIFun { //title UILabel *titleLabel = [[UILabel alloc] init]; titleLabel.textAlignment = NSTextAlignmentCenter; titleLabel.font = [UIFont boldSystemFontOfSize:18.0]; titleLabel.textColor = [UIColor blackColor]; titleLabel.translatesAutoresizingMaskIntoConstraints = NO; [self.navBarBGView addSubview:titleLabel]; self.MytitleLabel = titleLabel; //selectTipImageView UIImageView *selectTip = [[UIImageView alloc] init]; selectTip.image = [UIImage imageNamed:@"upload_image_arrow"]; selectTip.translatesAutoresizingMaskIntoConstraints = NO; [self.navBarBGView addSubview:selectTip]; self.selectTip = selectTip; UIButton *tapBtn = [UIButton buttonWithType:UIButtonTypeCustom]; tapBtn.backgroundColor = [UIColor clearColor]; tapBtn.translatesAutoresizingMaskIntoConstraints = NO; [tapBtn addTarget:self action:@selector(selectGroupAction:) forControlEvents:UIControlEventTouchUpInside]; [self.navBarBGView addSubview:tapBtn]; [tapBtn mas_makeConstraints:^(MASConstraintMaker *make) { make.centerX.mas_equalTo(self.navBarBGView.mas_centerX); make.centerY.mas_equalTo(self.backBtn.mas_centerY); make.width.mas_equalTo(100); make.height.mas_equalTo(30); }]; [self setTitleLabelText:@""]; UIButton *rightBut = [[UIButton alloc] init]; [rightBut setTitle:NSLocalizedString(@"File_upload_Record_select_all",nil) forState:UIControlStateNormal]; [rightBut setTitle:NSLocalizedString(@"File_upload_cancel_select_all",nil) forState:UIControlStateSelected]; [rightBut setTitleColor:[UIColor hwColor:@"#01B7EA" alpha:1.0] forState:UIControlStateNormal]; rightBut.contentHorizontalAlignment = UIControlContentHorizontalAlignmentRight; [rightBut addTarget:self action:@selector(didClickSelectAllButton:) forControlEvents:UIControlEventTouchUpInside]; [self.navBarBGView addSubview:rightBut]; //多国语言适配 NSString *languageCode = [NSLocale preferredLanguages][0]; if([languageCode rangeOfString:@"ja-"].location != NSNotFound) { rightBut.titleLabel.font = [UIFont systemFontOfSize:13.0]; } [rightBut mas_makeConstraints:^(MASConstraintMaker *make) { make.right.mas_equalTo(-20); make.centerY.mas_equalTo(self.backBtn.mas_centerY); make.width.mas_equalTo(100); make.height.mas_equalTo(30); }]; } #pragma mark 设置相册标题 - (void)setTitleLabelText:(NSString*)title { self.MytitleLabel.text = title; CGFloat curWidth = [title boundingRectWithSize:CGSizeMake(SCREEN_W, 30) options:(NSStringDrawingUsesLineFragmentOrigin) attributes:@{NSFontAttributeName:[UIFont boldSystemFontOfSize:18.f]} context:nil].size.width; curWidth += 20; //HLog(@"title w:%f",curWidth); [self.MytitleLabel mas_remakeConstraints:^(MASConstraintMaker *make) { make.centerX.mas_equalTo(self.navBarBGView.mas_centerX).offset(-10); make.centerY.mas_equalTo(self.backBtn.mas_centerY); make.width.mas_equalTo(curWidth); make.height.mas_equalTo(30); }]; //self.MytitleLabel.backgroundColor = [UIColor greenColor]; [self.selectTip mas_makeConstraints:^(MASConstraintMaker *make) { make.left.mas_equalTo(self.MytitleLabel.mas_right).offset(2); make.centerY.mas_equalTo(self.backBtn.mas_centerY); make.width.mas_equalTo(15); make.height.mas_equalTo(15); }]; } #pragma mark 点击全选 - (void)didClickSelectAllButton:(UIButton*)but { if(!self.assets ||self.assets.count == 0){ return; } but.selected = !but.selected; if(but.selected){ [self.indexPathsForSelectedItems removeAllObjects]; [SVProgressHUD show]; for (int i= 0; i_isNotAllowed = NO; // mainBlock(^{ // // }); } }]; } //相册权限 if (![[TZImageManager manager] authorizationStatusAuthorized]){ KWeakSelf [PHPhotoLibrary requestAuthorization:^(PHAuthorizationStatus status) { if(status == PHAuthorizationStatusAuthorized){ dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1.0 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ [weakSelf.photoGroupView setupGroup]; [weakSelf delayedSetPhotoGroupViewFrameFun]; }); } else if (status == PHAuthorizationStatusDenied || status == PHAuthorizationStatusRestricted) { mainBlock(^{ // 用户拒绝授权或设备受限,提示用户去系统设置中开启权限 [weakSelf requestPhotoLibraryAccessWithAlert]; }); } }]; } } /** * 照片列表 */ - (void)setupPhotoListView { AJPhotoListView *collectionView = [[AJPhotoListView alloc] init]; collectionView.dataSource = self; collectionView.delegate = self; collectionView.translatesAutoresizingMaskIntoConstraints = NO; [self.view insertSubview:collectionView atIndex:0]; self.photoListView = collectionView; //空数据引入第三方开源处理 collectionView.emptyDataSetSource = self; collectionView.emptyDataSetDelegate = self; [collectionView mas_makeConstraints:^(MASConstraintMaker *make) { make.left.mas_equalTo(0); make.right.mas_equalTo(0); make.bottom.mas_equalTo(-(60 + safeArea)); make.top.equalTo(self.navBarBGView.mas_bottom).offset(0.f); }]; } /** * 照片列表 */ - (void)setupUploadFileBottomView { uploadFileBottomView *bottomView = [[uploadFileBottomView alloc] init]; [self.view insertSubview:bottomView atIndex:0]; self.uploadFileBottomV = bottomView; [bottomView mas_makeConstraints:^(MASConstraintMaker *make) { make.left.mas_equalTo(0); make.right.mas_equalTo(0); make.bottom.mas_equalTo(0); make.height.mas_equalTo(60 + safeArea); }]; //nas 不需要BaseInfo 相关信息了 修改逻辑 [self handelAfterGetBaseInfoModelData]; KWeakSelf bottomView.didClickUploadFile = ^{ [weakSelf gotoUploadFileRecordFun]; }; bottomView.didClickbottomFun = ^{ [weakSelf gotofileTransferPathCheckVCFun]; }; } /** * 相册 */ - (void)setupGroupView { AJPhotoGroupView *photoGroupView = [[AJPhotoGroupView alloc] init]; photoGroupView.my_delegate = self; photoGroupView.isPhotoType = _isPhotoType; [self.view insertSubview:photoGroupView belowSubview:self.navBarBGView]; self.photoGroupView = photoGroupView; photoGroupView.hidden = YES; photoGroupView.translatesAutoresizingMaskIntoConstraints = NO; [self.photoGroupView setupGroup]; [self delayedSetPhotoGroupViewFrameFun]; } #pragma mark 延时设置photoGroupView frame - (void)delayedSetPhotoGroupViewFrameFun { dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1.0 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ NSInteger maxCount = 6; if(self.photoGroupView.albumGroups.count < maxCount){ maxCount = self.photoGroupView.albumGroups.count; } [self.photoGroupView mas_remakeConstraints:^(MASConstraintMaker *make) { make.left.mas_equalTo(0); make.right.mas_equalTo(0); make.height.mas_equalTo(60.0 * maxCount); make.top.equalTo(self.navBarBGView.mas_bottom).offset(0.f); }]; }); } #pragma mark - 相册切换 - (void)selectGroupAction:(UIButton *)sender { //无权限 if (self.isNotAllowed) { return; } if (self.photoGroupView.hidden) { [self bgMaskView]; self.bgMaskView.hidden = NO; self.photoGroupView.hidden = NO; [UIView animateWithDuration:0.3 animations:^{ CGRect rect = self.photoGroupView.frame; rect.origin.y = CGRectGetMaxY(self.navBarBGView.frame); self.photoGroupView.frame = rect; self.selectTip.transform = CGAffineTransformMakeRotation(M_PI); }]; } else { [self hidenGroupView]; } } - (void)hidenGroupView { //[self.bgMaskView removeFromSuperview]; self.bgMaskView.hidden = YES; [UIView animateWithDuration:0.3 animations:^{ CGRect rect = self.photoGroupView.frame; rect.origin.y = -SCREEN_H; self.photoGroupView.frame = rect; self.selectTip.transform = CGAffineTransformIdentity; }completion:^(BOOL finished) { self.photoGroupView.hidden = YES; }]; } #pragma mark - 遮罩背景 - (UIView *)bgMaskView { if (_bgMaskView == nil) { UIView *bgMaskView = [[UIView alloc] init]; bgMaskView.alpha = 0.5; bgMaskView.translatesAutoresizingMaskIntoConstraints = NO; bgMaskView.backgroundColor = [UIColor blackColor]; //[self.view insertSubview:bgMaskView aboveSubview:self.photoListView]; [self.view insertSubview:bgMaskView belowSubview:self.photoGroupView]; bgMaskView.userInteractionEnabled = YES; [bgMaskView addGestureRecognizer:[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapBgMaskView:)]]; _bgMaskView = bgMaskView; [bgMaskView mas_makeConstraints:^(MASConstraintMaker *make) { make.left.mas_equalTo(0); make.right.mas_equalTo(0); make.bottom.mas_equalTo(0); make.top.equalTo(self.navBarBGView.mas_bottom).offset(0.f); }]; } return _bgMaskView; } - (void)tapBgMaskView:(UITapGestureRecognizer *)sender { if (!self.photoGroupView.hidden) { [self hidenGroupView]; } } #pragma mark - BoPhotoGroupViewProtocol - (void)didSelectGroup:(TZAlbumModel *)model { [self loadAssets:model]; [self setTitleLabelText:model.name]; [self hidenGroupView]; } //加载图片 - (void)loadAssets:(TZAlbumModel *)model { [self.indexPathsForSelectedItems removeAllObjects]; [self.assets removeAllObjects]; [[TZImageManager manager] getAssetsFromFetchResult:model.result completion:^(NSArray *models) { self->_assets = [NSMutableArray arrayWithArray:models]; [self.photoListView scrollRectToVisible:CGRectMake(0, 0, 1, 1) animated:YES]; [self.photoListView reloadData]; }]; } #pragma mark - uicollectionDelegate - (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section { return self.assets.count; } - (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath { static NSString *cellIdentifer = @"cell"; AJPhotoListCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:cellIdentifer forIndexPath:indexPath]; BOOL isSelected = [self.indexPathsForSelectedItems containsObject:self.assets[indexPath.row]]; [cell bind:self.assets[indexPath.row] selectionFilter:self.selectionFilter isSelected:isSelected]; KWeakSelf cell.didClckSelectBut = ^(BOOL isSelect) { [weakSelf handlCellSelectFunBy:indexPath]; }; return cell; } - (UIEdgeInsets)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout insetForSectionAtIndex:(NSInteger)section { return UIEdgeInsetsMake(5, 5, 5, 5); } - (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath { CGFloat wh = (collectionView.bounds.size.width - 20)/3.0; return CGSizeMake(wh, wh); } - (CGFloat)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout minimumLineSpacingForSectionAtIndex:(NSInteger)section { return 5.0; } - (CGFloat)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout minimumInteritemSpacingForSectionAtIndex:(NSInteger)section { return 5.0; } - (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath { NSInteger curRow = indexPath.row; PhotoPreviewViewController *vc =[PhotoPreviewViewController new]; vc.assets = _assets; vc.currentIndex = curRow; vc.indexPathsForSelectedItems = _indexPathsForSelectedItems; //vc.maximumNumberOfSelection = _maximumNumberOfSelection; vc.minimumNumberOfSelection = _minimumNumberOfSelection; vc.availableStorage = self.uploadFileBottomV.availableStorage; vc.isPhotoType = _isPhotoType; [self.navigationController pushViewController:vc animated:YES]; KWeakSelf vc.changeSelectIndex = ^(NSMutableArray * _Nonnull indexPathsForSelectedItems) { [weakSelf refreshDataAndUIFunWith:indexPathsForSelectedItems]; }; } #pragma mark 空数据 - (UIImage *)imageForEmptyDataSet:(UIScrollView *)scrollView { NSString *imageName = @"common_no_data_pic"; return [UIImage imageNamed:imageName]; } - (NSAttributedString *)titleForEmptyDataSet:(UIScrollView *)scrollView { NSString *text = NSLocalizedString(@"common_no_data_tip",nil); if(isNotPhotoPermission){ text = NSLocalizedString(@"enable_photo_permission_noData_tip",nil); } NSDictionary *attributes = @{NSFontAttributeName: [UIFont systemFontOfSize:16.0f], NSForegroundColorAttributeName: HW999999Color}; return [[NSAttributedString alloc] initWithString:text attributes:attributes]; } //调整图片位置 - (CGFloat)verticalOffsetForEmptyDataSet:(UIScrollView *)scrollView { return -50; } #pragma mark 从详情页回来 刷新数据和UI - (void)refreshDataAndUIFunWith:(NSMutableArray *)indexPathsForSelectedItems { self.indexPathsForSelectedItems = indexPathsForSelectedItems; [self refreshAllDataFun]; } #pragma mark 刷新所有数据 - (void)refreshAllDataFun { [self setDataToBottomViewFun]; [self.photoListView reloadData]; } #pragma mark 处理点击选中相关 - (void)handlCellSelectFunBy:(NSIndexPath *)indexPath { AJPhotoListCell *cell = (AJPhotoListCell *)[self.photoListView cellForItemAtIndexPath:indexPath]; TZAssetModel *model = self.assets[indexPath.row]; //超出最大限制 // if (self.indexPathsForSelectedItems.count >= self.maximumNumberOfSelection ) { // return; // } //取消选中 if ([self.indexPathsForSelectedItems containsObject:model]) { [self.indexPathsForSelectedItems removeObject:model]; model.isSelected = NO; [cell isSelected:NO]; [self setDataToBottomViewFun]; dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ [self.uploadFileBottomV setUploadButtonCanClickFunBy:YES]; }); } else {//选中 [self didSelectModel:model isLastModel:YES]; [cell isSelected:YES]; } } #pragma mark 选中某个cell - (void)didSelectModel:(TZAssetModel *)model isLastModel:(BOOL)isLast {//选中 [self.indexPathsForSelectedItems addObject:model]; model.isSelected = YES; if(!model.totalBytes) { PHImageRequestOptions *options = [[PHImageRequestOptions alloc] init]; options.networkAccessAllowed = YES; // Allow downloading from iCloud options.version = PHImageRequestOptionsVersionCurrent; options.deliveryMode = PHImageRequestOptionsDeliveryModeHighQualityFormat; [[PHImageManager defaultManager] requestImageDataForAsset:model.asset options:options resultHandler:^(NSData * _Nullable imageData, NSString * _Nullable dataUTI, UIImageOrientation orientation, NSDictionary * _Nullable info) { // 直接得到最终的 NSData 数据 if (imageData) { //model.imageData = imageData; model.totalBytes = [imageData length]; } if(model.type != TZAssetModelMediaTypeVideo){ [self setDataToBottomViewFun]; } if(isLast){ dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ [SVProgressHUD dismiss]; [self.uploadFileBottomV setUploadButtonCanClickFunBy:YES]; }); } }]; if(model.type == TZAssetModelMediaTypeVideo){ PHVideoRequestOptions *options = [[PHVideoRequestOptions alloc] init]; options.version = PHVideoRequestOptionsVersionOriginal; options.networkAccessAllowed = YES; // Allow downloading from iCloud [[PHImageManager defaultManager] requestAVAssetForVideo:model.asset options:options resultHandler:^(AVAsset *asset, AVAudioMix *audioMix, NSDictionary *info) { if ([asset isKindOfClass:[AVURLAsset class]]) { AVURLAsset* urlAsset = (AVURLAsset*)asset; //NSData *videoData = [NSData dataWithContentsOfURL:urlAsset.URL]; NSNumber *size; [urlAsset.URL getResourceValue:&size forKey:NSURLFileSizeKey error:nil]; //NSLog(@"size is %f",[size floatValue]/(1024.0*1024.0)); //model.videoData = videoData; //model.totalBytes = [videoData length]; model.totalBytes = size.longLongValue; [self setDataToBottomViewFun]; } if(isLast){ dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ [SVProgressHUD dismiss]; [self.uploadFileBottomV setUploadButtonCanClickFunBy:YES]; }); } }]; } } else{ [self setDataToBottomViewFun]; if(isLast){ dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.2 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ [SVProgressHUD dismiss]; [self.uploadFileBottomV setUploadButtonCanClickFunBy:YES]; }); } } } #pragma mark 同步数据到底部 - (void)setDataToBottomViewFun { mainBlock(^{ self.uploadFileBottomV.indexPathsForSelectedItems = self.indexPathsForSelectedItems; }); } #pragma mark - getter/setter - (NSMutableArray *)assets { if (!_assets) { _assets = [[NSMutableArray alloc] init]; } return _assets; } - (NSMutableArray *)indexPathsForSelectedItems { if (!_indexPathsForSelectedItems) { _indexPathsForSelectedItems = [[NSMutableArray alloc] init]; } return _indexPathsForSelectedItems; } #pragma mark 跳转上传记录 - (void)gotoUploadFileRecordFun { uploadFileRecordViewController *vc = [uploadFileRecordViewController new]; [self.navigationController pushViewController:vc animated:YES]; vc.isUploadingType = YES; [vc gotoUploadFile:_indexPathsForSelectedItems]; if(_isPhotoType){ //数据埋点 [[netWorkManager shareInstance] DataEmbeddingPointBy:3 withEventValue:@"Image_upload"]; } else{ //数据埋点 [[netWorkManager shareInstance] DataEmbeddingPointBy:3 withEventValue:@"Video_upload"]; } } - (void)getCouldPhoneBaseInfoFun:(NSNotification*)not { baseInfoModel = [not object]; //HLog(@"%@",baseInfoModel); [self handelAfterGetBaseInfoModelData]; } - (void)handelAfterGetBaseInfoModelData { // if(!baseInfoModel || ![baseInfoModel isKindOfClass:[couldPhoneBaseInfoModel class]]){ // return; // } NSString * uploadDefaultPath = [HWDataManager getStringWithKey:stringKeyAddSn(Const_photo_upload_default_path)]; if(!uploadDefaultPath || uploadDefaultPath.length == 0){ [HWDataManager setStringWithKey:stringKeyAddSn(Const_photo_upload_default_path) value:Const_default_upload_path]; uploadDefaultPath = Const_default_upload_path; } BOOL isExtraFileType = NO; BOOL isExtraPathFind = NO; if(uploadDefaultPath){ if(![uploadDefaultPath containsString:@"sdcard/"]){ isExtraFileType = YES; } } if(uploadDefaultPath && ksharedAppDelegate.cloudPhoneExtraFileListMod){ NSArray*arr = ksharedAppDelegate.cloudPhoneExtraFileListMod.data; for (cloudPhoneExtraFileModel*model in arr) { if([uploadDefaultPath containsString:model.extraPath]){ NSString * availableStorage = @""; NSInteger totalSize_k = model.extraAvableSize / 1024; if(totalSize_k < 1024){ availableStorage = [[NSString alloc] initWithFormat:@"%ldKB",totalSize_k]; } else if( totalSize_k >= 1024 && totalSize_k < 1024*1024){ availableStorage = [[NSString alloc] initWithFormat:@"%.2fMB",totalSize_k/1024.0]; } else{ availableStorage = [[NSString alloc] initWithFormat:@"%.2fG",totalSize_k/1024.0/1024.0]; } self.uploadFileBottomV.availableStorage = availableStorage; self.uploadFileBottomV.available = model.extraAvableSize; isExtraPathFind = YES; break; } } } if(!isExtraPathFind){ // self.uploadFileBottomV.availableStorage = baseInfoModel.data.availableStorage; // self.uploadFileBottomV.available = baseInfoModel.data.available; } if(isExtraFileType && !isExtraPathFind){ self.uploadFileBottomV.isExtraFileAndNotFindPathType = YES; } else{ self.uploadFileBottomV.isExtraFileAndNotFindPathType = NO; } [self setDataToBottomViewFun]; } - (void)gotofileTransferPathCheckVCFun { fileTransferPathCheckViewController *vc = [fileTransferPathCheckViewController new]; vc.curType = 1; [self.navigationController pushViewController:vc animated:YES]; KWeakSelf vc.didChangeSavePathFun = ^{ [weakSelf.uploadFileBottomV setSavePathDataFun]; [weakSelf handelAfterGetBaseInfoModelData]; }; } - (void)viewDidAppear:(BOOL)animated{ [super viewDidAppear:animated]; if(!_isNotFirstType){ [self showUploadTipFun]; //权限访问时 重新拿数据 验证iOS 15.0有效 17.5.1无效 (viewDidAppear 和applicationDidBecomeActive 均不走) [self.photoGroupView setupGroup]; [self delayedSetPhotoGroupViewFrameFun]; _isNotFirstType = YES; } } - (void)viewWillDisappear:(BOOL)animated { [super viewWillDisappear:animated]; [SVProgressHUD dismiss]; } - (void)showUploadTipFun { BOOL didReadUploadTipType = [HWDataManager getBoolWithKey:Const_file_upLoad_need_read]; if(didReadUploadTipType){ return; } //KWeakSelf /*弹窗提示恢复出厂*/ ComontAlretViewController *nextVC = [[ComontAlretViewController alloc] initWithTiTle:nil msg:NSLocalizedString(@"upload_download_need_read_msg",nil) imageStr:nil cancelTitle:NSLocalizedString(@"guide_set_pwd_guide_know",nil) okTitle:nil isOkBtnHighlight:NO didClickOk:^{ } didClickCancel:^{ [HWDataManager setBoolWithKey:Const_file_upLoad_need_read value:YES]; }]; nextVC.modalPresentationStyle = UIModalPresentationCustom; [self presentViewController:nextVC animated:YES completion:^{ nextVC.view.superview.backgroundColor = [UIColor clearColor]; }]; } #pragma mark 用户拒接授权相册 - (void)requestPhotoLibraryAccessWithAlert { isNotPhotoPermission = YES; [self.photoListView reloadData]; //KWeakSelf /*弹窗提示重启*/ ComontAlretViewController *nextVC = [[ComontAlretViewController alloc] initWithTiTle:NSLocalizedString(@"enable_photo_permission",nil) msg:NSLocalizedString(@"enable_photo_permission_tip",nil) imageStr:@"" cancelTitle:NSLocalizedString(@"other_cancel",nil) okTitle:NSLocalizedString(@"more_set",nil) isOkBtnHighlight:YES didClickOk:^{ // 打开应用的设置页面 NSURL *url = [NSURL URLWithString:UIApplicationOpenSettingsURLString]; if ([[UIApplication sharedApplication] canOpenURL:url]) { [[UIApplication sharedApplication] openURL:url options:@{} completionHandler:nil]; } } didClickCancel:^{ }]; nextVC.modalPresentationStyle = UIModalPresentationCustom; [self presentViewController:nextVC animated:YES completion:^{ nextVC.view.superview.backgroundColor = [UIColor clearColor]; }]; } @end