0

In Xamarin.Forms application, i am using displaying a file picker to user using UIDocumentPickerViewController. It has one property DirectoryUrl which can be used iOS 13.0 and above. Basically as per documentation this property sets the initially directory for file picker.

Documentation Link: https://developer.apple.com/documentation/uikit/uidocumentpickerviewcontroller/3183918-directoryurl

If i set the DirectoryUrl property, then it opens up the file picker with initially set directory with browse tab selected in file picker but cancel button is not visible on top.

When user goes to recent tab and come back to browse tab then only the cancel button gets visible.

If user cancel the file picker using cancel button on recent tab, then also cancel button on browse tab will not be visible.

Code:

var allowedUtis = new string[]
{
    UTType.Content,
    UTType.Item,
    UTType.Data
};

if (allowedTypes != null)
{
    allowedUtis = allowedTypes;
}

var documentPicker = new UIDocumentPickerViewController(allowedUtis, UIDocumentPickerMode.Import);
if (UIDevice.CurrentDevice.CheckSystemVersion(13, 0))
{
    // DirectoryUrl property only works in iOS SDK 13.0+
    // _documentsPath is path for folder
    docPicker.DirectoryUrl = new NSUrl(_documentsPath, true);
}
documentPicker.DidPickDocument += this.DocumentPicker_DidPickDocument;
documentPicker.WasCancelled += this.DocumentPicker_WasCancelled;
documentPicker.DidPickDocumentAtUrls += this.DocumentPicker_DidPickDocumentAtUrls;

UIViewController viewController = GetActiveViewController();
viewController.PresentViewController(documentPicker, true, null);
manojkulkarni30
  • 304
  • 1
  • 2
  • 12
  • Please provide us with a bit of code so that we can know what you have tried already. https://stackoverflow.com/help/minimal-reproducible-example – Mihail Duchev May 05 '20 at 17:07

1 Answers1

0

This is a known bug which I have reported to Apple. Sadly it still isn't fixed in iOS 14 beta.

Nic Hubbard
  • 41,587
  • 63
  • 251
  • 412