Trying to get my App to work on iOS now - and wow! This is way harder than I thought.
OK, So I have a filepicker that picks a file. pretty simple (code below.) . With iOs. The file picker dialog opens, and I can click the file I want , but nothing happens - until I hit cancel, then the code continues to run... (pickresult != null).. it is null - code stops... https://photos.app.goo.gl/fGD5SPtCqdMYE8AS7
var customFileType =
new FilePickerFileType(new Dictionary<DevicePlatform, IEnumerable<string>>
{
{ DevicePlatform.iOS, new[] { "com.microsoft.word.doc" } }, // or general UTType values
{ DevicePlatform.Android, new[] { "application/doc" } },
{ DevicePlatform.UWP, new[] { ".doc" } },
{ DevicePlatform.Tizen, new[] { "*/*" } },
{ DevicePlatform.macOS, new[] { "doc" } }, // or general UTType values
});
string OutupPath;
var pickResult = await FilePicker.PickAsync(new PickOptions
{
FileTypes = customFileType,
PickerTitle = "Select Doc File"
}) ;
if (pickResult != null)
{
OutupPath = pickResult.FullPath.ToString();
App.docFilePath = OutupPath;
LoadingText = pickResult.FileName.ToString();
DbFileName = LoadingText;
}
else {
return;
}
Note - I am developing on Win10 vs 2022. And I am new to iOs. I just got my apple dev account up and running. The Android version and Windows version of this work flawlessly.
Not sure where I should be looking to solve this glitch.
https://photos.app.goo.gl/fGD5SPtCqdMYE8AS7
Original code with no options
private async void Button_Clicked(object sender, EventArgs e)
{
var pickResult = await FilePicker.PickAsync();
if (pickResult != null)
{
FileLabel.Text = pickResult.FileName.ToString();
}
else {
await DisplayAlert("Alert", "No File Selected", "OK");
}
}