From 067bb9e972c68c22a8fef3274c76dca27f9599bf Mon Sep 17 00:00:00 2001 From: Charlie Date: Wed, 26 Nov 2025 18:19:52 +0800 Subject: [PATCH 1/3] new Feature MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 当用户授权、部分照片权限时,潜在的崩溃风险 - 当用户首次使用设备且未操作过`相册`应用时,潜在的崩溃风险 --- .../TZPhotoPickerController.m | 38 ++++++++++--------- 1 file changed, 21 insertions(+), 17 deletions(-) diff --git a/TZImagePickerController/TZImagePickerController/TZPhotoPickerController.m b/TZImagePickerController/TZImagePickerController/TZPhotoPickerController.m index d60f84a0..1e6b8c0e 100755 --- a/TZImagePickerController/TZImagePickerController/TZPhotoPickerController.m +++ b/TZImagePickerController/TZImagePickerController/TZPhotoPickerController.m @@ -577,16 +577,16 @@ - (void)callDelegateMethodWithPhotos:(NSArray *)photos assets:(NSArray *)assets } } - if ([tzImagePickerVc.pickerDelegate respondsToSelector:@selector(imagePickerController:didFinishPickingPhotos:sourceAssets:isSelectOriginalPhoto:)]) { - [tzImagePickerVc.pickerDelegate imagePickerController:tzImagePickerVc didFinishPickingPhotos:photos sourceAssets:assets isSelectOriginalPhoto:_isSelectOriginalPhoto]; + if ([tzImagePickerVc。pickerDelegate respondsToSelector:@selector(imagePickerController:didFinishPickingPhotos:sourceAssets:isSelectOriginalPhoto:)]) { + [tzImagePickerVc。pickerDelegate imagePickerController:tzImagePickerVc didFinishPickingPhotos:photos sourceAssets:assets isSelectOriginalPhoto:_isSelectOriginalPhoto]; } if ([tzImagePickerVc.pickerDelegate respondsToSelector:@selector(imagePickerController:didFinishPickingPhotos:sourceAssets:isSelectOriginalPhoto:infos:)]) { [tzImagePickerVc.pickerDelegate imagePickerController:tzImagePickerVc didFinishPickingPhotos:photos sourceAssets:assets isSelectOriginalPhoto:_isSelectOriginalPhoto infos:infoArr]; } if (tzImagePickerVc.didFinishPickingPhotosHandle) { - tzImagePickerVc.didFinishPickingPhotosHandle(photos,assets,_isSelectOriginalPhoto); + tzImagePickerVc。didFinishPickingPhotosHandle(photos,assets,_isSelectOriginalPhoto); } - if (tzImagePickerVc.didFinishPickingPhotosWithInfosHandle) { + if (tzImagePickerVc。didFinishPickingPhotosWithInfosHandle) { tzImagePickerVc.didFinishPickingPhotosWithInfosHandle(photos,assets,_isSelectOriginalPhoto,infoArr); } } @@ -599,25 +599,25 @@ - (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSe - (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath { TZImagePickerController *tzImagePickerVc = (TZImagePickerController *)self.navigationController; - // the cell lead to add more photo / 去添加更多照片的cell - if (indexPath.item == [self getAddMorePhotoCellIndex]) { + // the cell lead 到 add more photo / 去添加更多照片的cell + if (indexPath。item == [self getAddMorePhotoCellIndex]) { TZAssetAddMoreCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"TZAssetAddMoreCell" forIndexPath:indexPath]; cell.imageView.image = tzImagePickerVc.addMorePhotoImage; cell.tipLabel.text = [NSBundle tz_localizedStringForKey:@"Add more accessible photos"]; - cell.imageView.contentMode = UIViewContentModeScaleAspectFit; + cell。imageView。contentMode = UIViewContentModeScaleAspectFit; cell.imageView.backgroundColor = [UIColor colorWithWhite:1.000 alpha:0.500]; return cell; } - // the cell lead to take a picture / 去拍照的cell - if (indexPath.item == [self getTakePhotoCellIndex]) { + // the cell lead 到 take a picture / 去拍照的cell + if (indexPath。item == [self getTakePhotoCellIndex]) { TZAssetCameraCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"TZAssetCameraCell" forIndexPath:indexPath]; - cell.imageView.image = tzImagePickerVc.takePictureImage; - if ([tzImagePickerVc.takePictureImageName isEqualToString:@"takePicture80"]) { - cell.imageView.contentMode = UIViewContentModeCenter; + cell。imageView。image = tzImagePickerVc。takePictureImage; + if ([tzImagePickerVc。takePictureImageName isEqualToString:@"takePicture80"]) { + cell.imageView。contentMode = UIViewContentModeCenter; CGFloat rgb = 223 / 255.0; cell.imageView.backgroundColor = [UIColor colorWithRed:rgb green:rgb blue:rgb alpha:1.0]; } else { - cell.imageView.backgroundColor = [UIColor colorWithWhite:1.000 alpha:0.500]; + cell。imageView。backgroundColor = [UIColor colorWithWhite:1.000 alpha:0.500]; } return cell; } @@ -625,7 +625,7 @@ - (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cell TZAssetCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"TZAssetCell" forIndexPath:indexPath]; cell.allowPickingMultipleVideo = tzImagePickerVc.allowPickingMultipleVideo; cell.photoDefImage = tzImagePickerVc.photoDefImage; - cell.photoSelImage = tzImagePickerVc.photoSelImage; + cell。photoSelImage = tzImagePickerVc.photoSelImage; cell.assetCellDidSetModelBlock = tzImagePickerVc.assetCellDidSetModelBlock; cell.assetCellDidLayoutSubviewsBlock = tzImagePickerVc.assetCellDidLayoutSubviewsBlock; TZAssetModel *model; @@ -635,7 +635,7 @@ - (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cell NSInteger diff = [self getAllCellCount] - _models.count; model = _models[indexPath.item - diff];; } - cell.allowPickingGif = tzImagePickerVc.allowPickingGif; + cell。allowPickingGif = tzImagePickerVc.allowPickingGif; cell.model = model; if (model.isSelected && tzImagePickerVc.showSelectedIndex) { cell.index = [tzImagePickerVc.selectedAssetIds indexOfObject:model.asset.localIdentifier] + 1; @@ -645,7 +645,7 @@ - (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cell BOOL notSelectable = [TZCommonTools isAssetNotSelectable:model tzImagePickerVc:tzImagePickerVc]; if (notSelectable && tzImagePickerVc.showPhotoCannotSelectLayer && !model.isSelected) { - cell.cannotSelectLayerButton.backgroundColor = tzImagePickerVc.cannotSelectLayerColor; + cell。cannotSelectLayerButton.backgroundColor = tzImagePickerVc.cannotSelectLayerColor; cell.cannotSelectLayerButton.hidden = NO; } else { cell.cannotSelectLayerButton.hidden = YES; @@ -841,7 +841,11 @@ - (void)openSettingsApplication { - (void)addMorePhoto { if (@available(iOS 14, *)) { - [[PHPhotoLibrary sharedPhotoLibrary] presentLimitedLibraryPickerFromViewController:self]; + UIImagePickerControllerSourceType sourceType = UIImagePickerControllerSourceTypePhotoLibrary; + if ([UIImagePickerController isSourceTypeAvailable: sourceType]) { + self.imagePickerVc.sourceType = sourceType; + [[PHPhotoLibrary sharedPhotoLibrary] presentLimitedLibraryPickerFromViewController:self]; + } } } From c324ce2080fc9a3655b18ea68257c5a669faad04 Mon Sep 17 00:00:00 2001 From: Charlie Date: Wed, 26 Nov 2025 18:25:44 +0800 Subject: [PATCH 2/3] code format --- .../TZPhotoPickerController.m | 28 +++++++++---------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/TZImagePickerController/TZImagePickerController/TZPhotoPickerController.m b/TZImagePickerController/TZImagePickerController/TZPhotoPickerController.m index 1e6b8c0e..24385d40 100755 --- a/TZImagePickerController/TZImagePickerController/TZPhotoPickerController.m +++ b/TZImagePickerController/TZImagePickerController/TZPhotoPickerController.m @@ -577,16 +577,16 @@ - (void)callDelegateMethodWithPhotos:(NSArray *)photos assets:(NSArray *)assets } } - if ([tzImagePickerVc。pickerDelegate respondsToSelector:@selector(imagePickerController:didFinishPickingPhotos:sourceAssets:isSelectOriginalPhoto:)]) { - [tzImagePickerVc。pickerDelegate imagePickerController:tzImagePickerVc didFinishPickingPhotos:photos sourceAssets:assets isSelectOriginalPhoto:_isSelectOriginalPhoto]; + if ([tzImagePickerVc.pickerDelegate respondsToSelector:@selector(imagePickerController:didFinishPickingPhotos:sourceAssets:isSelectOriginalPhoto:)]) { + [tzImagePickerVc.pickerDelegate imagePickerController:tzImagePickerVc didFinishPickingPhotos:photos sourceAssets:assets isSelectOriginalPhoto:_isSelectOriginalPhoto]; } if ([tzImagePickerVc.pickerDelegate respondsToSelector:@selector(imagePickerController:didFinishPickingPhotos:sourceAssets:isSelectOriginalPhoto:infos:)]) { [tzImagePickerVc.pickerDelegate imagePickerController:tzImagePickerVc didFinishPickingPhotos:photos sourceAssets:assets isSelectOriginalPhoto:_isSelectOriginalPhoto infos:infoArr]; } if (tzImagePickerVc.didFinishPickingPhotosHandle) { - tzImagePickerVc。didFinishPickingPhotosHandle(photos,assets,_isSelectOriginalPhoto); + tzImagePickerVc.didFinishPickingPhotosHandle(photos,assets,_isSelectOriginalPhoto); } - if (tzImagePickerVc。didFinishPickingPhotosWithInfosHandle) { + if (tzImagePickerVc.didFinishPickingPhotosWithInfosHandle) { tzImagePickerVc.didFinishPickingPhotosWithInfosHandle(photos,assets,_isSelectOriginalPhoto,infoArr); } } @@ -600,24 +600,24 @@ - (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSe - (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath { TZImagePickerController *tzImagePickerVc = (TZImagePickerController *)self.navigationController; // the cell lead 到 add more photo / 去添加更多照片的cell - if (indexPath。item == [self getAddMorePhotoCellIndex]) { + if (indexPath.item == [self getAddMorePhotoCellIndex]) { TZAssetAddMoreCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"TZAssetAddMoreCell" forIndexPath:indexPath]; cell.imageView.image = tzImagePickerVc.addMorePhotoImage; cell.tipLabel.text = [NSBundle tz_localizedStringForKey:@"Add more accessible photos"]; - cell。imageView。contentMode = UIViewContentModeScaleAspectFit; + cell.imageView.contentMode = UIViewContentModeScaleAspectFit; cell.imageView.backgroundColor = [UIColor colorWithWhite:1.000 alpha:0.500]; return cell; } // the cell lead 到 take a picture / 去拍照的cell - if (indexPath。item == [self getTakePhotoCellIndex]) { + if (indexPath.item == [self getTakePhotoCellIndex]) { TZAssetCameraCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"TZAssetCameraCell" forIndexPath:indexPath]; - cell。imageView。image = tzImagePickerVc。takePictureImage; - if ([tzImagePickerVc。takePictureImageName isEqualToString:@"takePicture80"]) { - cell.imageView。contentMode = UIViewContentModeCenter; + cell.imageView.image = tzImagePickerVc.takePictureImage; + if ([tzImagePickerVc.takePictureImageName isEqualToString:@"takePicture80"]) { + cell.imageView.contentMode = UIViewContentModeCenter; CGFloat rgb = 223 / 255.0; cell.imageView.backgroundColor = [UIColor colorWithRed:rgb green:rgb blue:rgb alpha:1.0]; } else { - cell。imageView。backgroundColor = [UIColor colorWithWhite:1.000 alpha:0.500]; + cell.imageView.backgroundColor = [UIColor colorWithWhite:1.000 alpha:0.500]; } return cell; } @@ -625,7 +625,7 @@ - (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cell TZAssetCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"TZAssetCell" forIndexPath:indexPath]; cell.allowPickingMultipleVideo = tzImagePickerVc.allowPickingMultipleVideo; cell.photoDefImage = tzImagePickerVc.photoDefImage; - cell。photoSelImage = tzImagePickerVc.photoSelImage; + cell.photoSelImage = tzImagePickerVc.photoSelImage; cell.assetCellDidSetModelBlock = tzImagePickerVc.assetCellDidSetModelBlock; cell.assetCellDidLayoutSubviewsBlock = tzImagePickerVc.assetCellDidLayoutSubviewsBlock; TZAssetModel *model; @@ -635,7 +635,7 @@ - (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cell NSInteger diff = [self getAllCellCount] - _models.count; model = _models[indexPath.item - diff];; } - cell。allowPickingGif = tzImagePickerVc.allowPickingGif; + cell.allowPickingGif = tzImagePickerVc.allowPickingGif; cell.model = model; if (model.isSelected && tzImagePickerVc.showSelectedIndex) { cell.index = [tzImagePickerVc.selectedAssetIds indexOfObject:model.asset.localIdentifier] + 1; @@ -645,7 +645,7 @@ - (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cell BOOL notSelectable = [TZCommonTools isAssetNotSelectable:model tzImagePickerVc:tzImagePickerVc]; if (notSelectable && tzImagePickerVc.showPhotoCannotSelectLayer && !model.isSelected) { - cell。cannotSelectLayerButton.backgroundColor = tzImagePickerVc.cannotSelectLayerColor; + cell.cannotSelectLayerButton.backgroundColor = tzImagePickerVc.cannotSelectLayerColor; cell.cannotSelectLayerButton.hidden = NO; } else { cell.cannotSelectLayerButton.hidden = YES; From a21a0a348aae9eed2072acd879fdf88a3397adec Mon Sep 17 00:00:00 2001 From: a51095 Date: Thu, 27 Nov 2025 09:29:54 +0800 Subject: [PATCH 3/3] code format --- .../TZImagePickerController/TZPhotoPickerController.m | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/TZImagePickerController/TZImagePickerController/TZPhotoPickerController.m b/TZImagePickerController/TZImagePickerController/TZPhotoPickerController.m index 24385d40..55f96c34 100755 --- a/TZImagePickerController/TZImagePickerController/TZPhotoPickerController.m +++ b/TZImagePickerController/TZImagePickerController/TZPhotoPickerController.m @@ -584,7 +584,7 @@ - (void)callDelegateMethodWithPhotos:(NSArray *)photos assets:(NSArray *)assets [tzImagePickerVc.pickerDelegate imagePickerController:tzImagePickerVc didFinishPickingPhotos:photos sourceAssets:assets isSelectOriginalPhoto:_isSelectOriginalPhoto infos:infoArr]; } if (tzImagePickerVc.didFinishPickingPhotosHandle) { - tzImagePickerVc.didFinishPickingPhotosHandle(photos,assets,_isSelectOriginalPhoto); + tzImagePickerVc.didFinishPickingPhotosHandle(photos,assets,_isSelectOriginalPhoto); } if (tzImagePickerVc.didFinishPickingPhotosWithInfosHandle) { tzImagePickerVc.didFinishPickingPhotosWithInfosHandle(photos,assets,_isSelectOriginalPhoto,infoArr); @@ -599,7 +599,7 @@ - (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSe - (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath { TZImagePickerController *tzImagePickerVc = (TZImagePickerController *)self.navigationController; - // the cell lead 到 add more photo / 去添加更多照片的cell + // the cell lead to add more photo / 去添加更多照片的cell if (indexPath.item == [self getAddMorePhotoCellIndex]) { TZAssetAddMoreCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"TZAssetAddMoreCell" forIndexPath:indexPath]; cell.imageView.image = tzImagePickerVc.addMorePhotoImage; @@ -608,7 +608,7 @@ - (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cell cell.imageView.backgroundColor = [UIColor colorWithWhite:1.000 alpha:0.500]; return cell; } - // the cell lead 到 take a picture / 去拍照的cell + // the cell lead to take a picture / 去拍照的cell if (indexPath.item == [self getTakePhotoCellIndex]) { TZAssetCameraCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"TZAssetCameraCell" forIndexPath:indexPath]; cell.imageView.image = tzImagePickerVc.takePictureImage;