Skip to content

Commit

Permalink
Merge pull request unoplatform#15572 from unoplatform/dev/mazi/ios-mu…
Browse files Browse the repository at this point in the history
…ltipick-photos

fix: Use `UIDocumentPickerViewController` if multiple files are picked
  • Loading branch information
jeromelaban authored Feb 21, 2024
2 parents 1feb6a2 + 2b8f954 commit 8fdab6e
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
5 changes: 4 additions & 1 deletion doc/articles/features/windows-storage-pickers.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
uid: Uno.Features.WSPickers
---

# Storage Pickers
# File and Folder Pickers

> [!TIP]
> This article covers Uno-specific information for the `Windows.Storage.Pickers` namespace. For a full description of the feature and instructions on using it, see [Windows.Storage.Pickers Namespace](https://learn.microsoft.com/uwp/api/windows.storage.pickers).
Expand Down Expand Up @@ -156,6 +156,9 @@ else

> [!NOTE]
> `SuggestedStartLocation` should be set to prevent crashes on UWP. `FileTypes` must include at least one item. You can add extensions in the format `.extension`, with the exception of `*` (asterisk) which allows picking any type of file.
>
> [!NOTE]
> On iOS, the built-in image picker does not support selection of multiple files. Therefore we fall back to the document picker instead. However, this requires you to specify not only the `SuggestedStartLocation` set to `PicturesLibrary`, but also specifying file type extensions in `FileTypeFilter` (e.g. `.jpg` and `.png`), otherwise OS will not display the Photos app as a file provider in the picker.
### FileSavePicker

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,13 @@
namespace UITests.Shared.Windows_Storage.Pickers
{
[Sample("Windows.Storage", ViewModelType = typeof(FileOpenPickerTestsViewModel), IsManualTest = true,
Description = "Allows testing all features of FileOpenPicker. Currently not supported on Android, iOS, and macOS. Not selecting a file should not cause an exception. Selecting a file should show information below the file picker buttons")]
Description =
"""
- Not selecting a file should not cause an exception.
- Selecting a file should show information below the file picker buttons.
- It should be possible to pick multiple files, even if PicturesLibrary is selected and .jpg is used as file type.
"""
)]
public sealed partial class FileOpenPickerTests : Page
{
public FileOpenPickerTests()
Expand Down
2 changes: 1 addition & 1 deletion src/Uno.UWP/Storage/Pickers/FileOpenPicker.iOS.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ private UIViewController GetViewController(bool multiple, TaskCompletionSource<N
{
switch (SuggestedStartLocation)
{
case PickerLocationId.PicturesLibrary:
case PickerLocationId.PicturesLibrary when !multiple: // As UIImagePickerController does not support multiple selection, we fall back to UIDocumentPickerViewController for multiple selection
return new UIImagePickerController()
{
SourceType = UIImagePickerControllerSourceType.PhotoLibrary,
Expand Down

0 comments on commit 8fdab6e

Please sign in to comment.