How to select multiples images on iOS using .NET MAUI

Wyllis Monteiro 41 Reputation points
2024-06-12T12:51:17.79+00:00

I'm using .NET MAUI and I want to select multiple images in iOS gallery (photos folder). I tried 2 libraries to do so.

The first one is FilePicker, here is the implementation

public class PicturePickerImpl : IPicturePicker
    {
        async public Task<IEnumerable<FileResult>> PickImages()
        {
            var options = new PickOptions
            {
                PickerTitle = "Select images",
                FileTypes = FilePickerFileType.Images
            };
            return await FilePicker.Default.PickMultipleAsync(options);
        }
    }

With this solution, I can select multiple images but I'm limited to 3 tabs : "Recents", "Shared", "Explorer", so I can't select in "Photos" folder

Doc : https://learn.microsoft.com/en-us/dotnet/maui/platform-integration/storage/file-picker?view=net-maui-8.0&tabs=android

The second one is MediaPicker, here is the implementation

public class PicturePickerImpl : IPicturePicker
    {
        async public Task<IEnumerable<FileResult>> PickImages()
        {
            var options = new MediaPickerOptions
            {
                Title = "TEST"
            };
            var files = new List<FileResult>()
            {
                {
                    await MediaPicker.PickPhotoAsync(options)
                }
            };
            return files;
        }
    }

With this solution, I can select just image in the good folder (Photos) but I need to select multiple images

Doc : https://learn.microsoft.com/fr-fr/dotnet/maui/platform-integration/device-media/picker?view=net-maui-8.0&tabs=android

  • Do I missed some information in the implementations to do what I expect ?
  • Is there another solution if I can't use this 2 libraries
Developer technologies .NET .NET MAUI
0 comments No comments
{count} votes

Accepted answer
  1. Yonglun Liu (Shanghai Wicresoft Co,.Ltd.) 50,126 Reputation points Microsoft External Staff
    2024-06-13T05:56:37.4233333+00:00

    Hello,

    Do I missed some information in the implementations to do what I expect ?

    No, MAUI does not currently provide an out-of-the-box API for multiple selections in the photo album.

    This is because the UIImagePickerController provided by iOS only has the ability to select one image. For multiple image selections, this actually requires the following two things.

    • Read the pictures in the album.
    • Put images into a custom CollectionView that supports multiple selections.

    Therefore, implementing multiple selection is not actually a configuration and call to the native API, but a complex process.

    Is there another solution if I can't use this 2 libraries

    For multiple selection in iOS, a user has already submitted a feature request in the Essentials - MediaPicker add method to select multiple images #6903. You can refer to the solution there.

    Best Regards,

    Alec Liu.


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.