When I try to select an image using the "File Picker" in Xamarin.Essentials, I can't select it only in the iOS simulator.
Xamarin.Essentials: File Picker
https://learn.microsoft.com/en-us/xamarin/essentials/file-picker?context=xamarin%2Fandroid&tabs=ios
var options = new PickOptions
{
PickerTitle = "Please select files",
FileTypes = FilePickerFileType.Images,
};
IEnumerable<FileResult> results = await FilePicker.PickMultipleAsync(options);
FilePickerFileType.Jpeg
setting did not work for me. In addition, I could not select a PDF file with FilePickerFileType.Pdf
settings.
However, when I launched the Android simulator, I was able to select the image successfully; only the iOS simulator was unable to select it.
Since PickerTitle
is also not reflected, it seems that options
itself is not enabled.
Also, even if I modified the customFileType
area as pointed out in the answer below, it still did not allow me to select files.
var customFileType =
new FilePickerFileType(new Dictionary<DevicePlatform, IEnumerable<string>>
{
{DevicePlatform.iOS, new[] { "com.adobe.pdf" , "public.jpeg" } },
});
var options = new PickOptions
{
PickerTitle = "Please select files",
//FileTypes = FilePickerFileType.Images,
FileTypes = customFileType,
};
IEnumerable<FileResult> results = await FilePicker.PickMultipleAsync(options);
Do I need to set anything else?
- Apple M1(macOS Monterey)
- Visual Studio for Mac 8.10.17
- Xamarin.Essentials 1.7.0
- Xamarin.Forms 5.0.0.2291