Commit 1cc21f9c authored by 马忠秋's avatar 马忠秋

fix dismiss not completion

parent ccd9496f
...@@ -227,55 +227,56 @@ RCT_EXPORT_METHOD(removeAllPhoto) { ...@@ -227,55 +227,56 @@ RCT_EXPORT_METHOD(removeAllPhoto) {
} }
- (void)imagePickerController:(UIImagePickerController*)picker didFinishPickingMediaWithInfo:(NSDictionary *)info { - (void)imagePickerController:(UIImagePickerController*)picker didFinishPickingMediaWithInfo:(NSDictionary *)info {
[picker dismissViewControllerAnimated:YES completion:nil]; [picker dismissViewControllerAnimated:YES completion:^{
NSString *type = [info objectForKey:UIImagePickerControllerMediaType]; NSString *type = [info objectForKey:UIImagePickerControllerMediaType];
if ([type isEqualToString:@"public.image"]) { if ([type isEqualToString:@"public.image"]) {
TZImagePickerController *tzImagePickerVc = [[TZImagePickerController alloc] initWithMaxImagesCount:1 delegate:nil]; TZImagePickerController *tzImagePickerVc = [[TZImagePickerController alloc] initWithMaxImagesCount:1 delegate:nil];
tzImagePickerVc.sortAscendingByModificationDate = NO; tzImagePickerVc.sortAscendingByModificationDate = NO;
[tzImagePickerVc showProgressHUD]; [tzImagePickerVc showProgressHUD];
UIImage *image = [info objectForKey:UIImagePickerControllerOriginalImage]; UIImage *image = [info objectForKey:UIImagePickerControllerOriginalImage];
// save photo and get asset / 保存图片,获取到asset // save photo and get asset / 保存图片,获取到asset
[[TZImageManager manager] savePhotoWithImage:image location:NULL completion:^(NSError *error){ [[TZImageManager manager] savePhotoWithImage:image location:NULL completion:^(NSError *error){
if (error) { if (error) {
[tzImagePickerVc hideProgressHUD]; [tzImagePickerVc hideProgressHUD];
NSLog(@"图片保存失败 %@",error); NSLog(@"图片保存失败 %@",error);
} else { } else {
[[TZImageManager manager] getCameraRollAlbum:NO allowPickingImage:YES needFetchAssets:YES completion:^(TZAlbumModel *model) { [[TZImageManager manager] getCameraRollAlbum:NO allowPickingImage:YES needFetchAssets:YES completion:^(TZAlbumModel *model) {
[[TZImageManager manager] getAssetsFromFetchResult:model.result allowPickingVideo:NO allowPickingImage:YES completion:^(NSArray<TZAssetModel *> *models) { [[TZImageManager manager] getAssetsFromFetchResult:model.result allowPickingVideo:NO allowPickingImage:YES completion:^(NSArray<TZAssetModel *> *models) {
[tzImagePickerVc hideProgressHUD]; [tzImagePickerVc hideProgressHUD];
TZAssetModel *assetModel = [models firstObject]; TZAssetModel *assetModel = [models firstObject];
BOOL isCrop = [self.cameraOptions sy_boolForKey:@"isCrop"]; BOOL isCrop = [self.cameraOptions sy_boolForKey:@"isCrop"];
BOOL showCropCircle = [self.cameraOptions sy_boolForKey:@"showCropCircle"]; BOOL showCropCircle = [self.cameraOptions sy_boolForKey:@"showCropCircle"];
NSInteger CropW = [self.cameraOptions sy_integerForKey:@"CropW"]; NSInteger CropW = [self.cameraOptions sy_integerForKey:@"CropW"];
NSInteger CropH = [self.cameraOptions sy_integerForKey:@"CropH"]; NSInteger CropH = [self.cameraOptions sy_integerForKey:@"CropH"];
NSInteger circleCropRadius = [self.cameraOptions sy_integerForKey:@"circleCropRadius"]; NSInteger circleCropRadius = [self.cameraOptions sy_integerForKey:@"circleCropRadius"];
NSInteger quality = [self.cameraOptions sy_integerForKey:@"quality"]; NSInteger quality = [self.cameraOptions sy_integerForKey:@"quality"];
if (isCrop) { if (isCrop) {
TZImagePickerController *imagePicker = [[TZImagePickerController alloc] initCropTypeWithAsset:assetModel.asset photo:image completion:^(UIImage *cropImage, id asset) { TZImagePickerController *imagePicker = [[TZImagePickerController alloc] initCropTypeWithAsset:assetModel.asset photo:image completion:^(UIImage *cropImage, id asset) {
[self invokeSuccessWithResult:@[[self handleImageData:cropImage quality:quality]]]; [self invokeSuccessWithResult:@[[self handleImageData:cropImage quality:quality]]];
}]; }];
imagePicker.allowCrop = isCrop; // 裁剪 imagePicker.allowCrop = isCrop; // 裁剪
if(showCropCircle) { if(showCropCircle) {
imagePicker.needCircleCrop = showCropCircle; //圆形裁剪 imagePicker.needCircleCrop = showCropCircle; //圆形裁剪
imagePicker.circleCropRadius = circleCropRadius; //圆形半径 imagePicker.circleCropRadius = circleCropRadius; //圆形半径
} else {
CGFloat x = ([[UIScreen mainScreen] bounds].size.width - CropW) / 2;
CGFloat y = ([[UIScreen mainScreen] bounds].size.height - CropH) / 2;
imagePicker.cropRect = CGRectMake(x,y,CropW,CropH);
}
[[self topViewController] presentViewController:imagePicker animated:YES completion:nil];
} else { } else {
CGFloat x = ([[UIScreen mainScreen] bounds].size.width - CropW) / 2; [self invokeSuccessWithResult:@[[self handleImageData:image quality:quality]]];
CGFloat y = ([[UIScreen mainScreen] bounds].size.height - CropH) / 2;
imagePicker.cropRect = CGRectMake(x,y,CropW,CropH);
} }
[[self topViewController] presentViewController:imagePicker animated:YES completion:nil]; }];
} else {
[self invokeSuccessWithResult:@[[self handleImageData:image quality:quality]]];
}
}]; }];
}]; }
} }];
}]; }
} }];
} }
- (void)imagePickerControllerDidCancel:(UIImagePickerController *)picker { - (void)imagePickerControllerDidCancel:(UIImagePickerController *)picker {
......
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