Skip to content
This repository was archived by the owner on Feb 22, 2023. It is now read-only.

Fix pickMultiImage launching camera and not returning on iOS when the… #4706

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -100,15 +100,13 @@ - (void)pickImageWithPHPicker:(int)maxImagesAllowed API_AVAILABLE(ios(14)) {
[self checkPhotoAuthorizationForAccessLevel];
}

- (void)pickImageWithUIImagePicker {
- (void)pickImageWithUIImagePicker:(int)imageSource maxImagesAllowed:(int)maxImagesAllowed {
_imagePickerController = [[UIImagePickerController alloc] init];
_imagePickerController.modalPresentationStyle = UIModalPresentationCurrentContext;
_imagePickerController.delegate = self;
_imagePickerController.mediaTypes = @[ (NSString *)kUTTypeImage ];

int imageSource = [[_arguments objectForKey:@"source"] intValue];

self.maxImagesAllowed = 1;
self.maxImagesAllowed = maxImagesAllowed;

switch (imageSource) {
case SOURCE_CAMERA:
Expand Down Expand Up @@ -144,18 +142,18 @@ - (void)handleMethodCall:(FlutterMethodCall *)call result:(FlutterResult)result
[self pickImageWithPHPicker:1];
} else {
// UIImagePicker is used
[self pickImageWithUIImagePicker];
[self pickImageWithUIImagePicker:SOURCE_GALLERY maxImagesAllowed:1];
}
} else {
[self pickImageWithUIImagePicker];
[self pickImageWithUIImagePicker:SOURCE_CAMERA maxImagesAllowed:1];
}
} else if ([@"pickMultiImage" isEqualToString:call.method]) {
self.result = result;
_arguments = call.arguments;
if (@available(iOS 14, *)) {
self.result = result;
_arguments = call.arguments;
[self pickImageWithPHPicker:0];
} else {
[self pickImageWithUIImagePicker];
[self pickImageWithUIImagePicker:SOURCE_GALLERY maxImagesAllowed:0];
}
} else if ([@"pickVideo" isEqualToString:call.method]) {
_imagePickerController = [[UIImagePickerController alloc] init];
Expand Down