1

I am using UIDocumentPickerViewController to browse through and let the user select a directory but on iOS 13 when this UIDocumentPickerViewController is displayed, the buttons that should be displayed like select/cancel and open/done are not displayed but when you tap on that location it does behaves like how it would if the buttons were visible. Also this problem is seen only on iOS 13. With the same code, the buttons are displayed on iOS 12. Any help is appreciated

I do have the navigation bar's tint color set to nil for an instance of UIDocumentBrowserViewController in AppDelegate didFinishLaunchingWithOptions.

if #available(iOS 11.0, *) {
    UINavigationBar.appearance(whenContainedInInstancesOf: [UIDocumentBrowserViewController.self]).tintColor = nil
} 


//Here is how UIDocumentPickerViewController is created and presented
let documentPickerViewController = UIDocumentPickerViewController(documentTypes:["public.folder"], in: .open)
...
...
...

self!.documentPickerViewController.delegate = self!
self!.documentPickerViewController.allowsMultipleSelection = true
self!.documentPickerViewController.modalPresentationStyle = .fullScreen     

self!.navigationController?.present(self!.documentPickerViewController, animated: true, completion:nil)

Here is a screenshot enter image description here

Edit : Here is the View Hierarchy - Not sure why DOCExportModeViewController on iOS 13. On iOS 12, it is a UIDocumentBrowserViewController for the same code. Any ideas how this can be fixed?

enter image description here

learner
  • 139
  • 1
  • 13
  • I observe this behavior in light mode, where buttons seem to be there but white on white, and therefore invisible. That's why they still work by knowing their position. – keeshux Feb 27 '20 at 14:17

2 Answers2

1

I found this quick fix, if the document ViewController or any other picker is used at multiple places:

if #available(iOS 11.0, *) {
    UINavigationBar.appearance(whenContainedInInstancesOf: [UIDocumentBrowserViewController.self]).tintColor = nil
}

If you are worried for one place or have different colors at different places you can set tint color in ViewWillAppear and reset it in ViewWillDisappear method.

Martin Braun
  • 10,906
  • 9
  • 64
  • 105
Waaheeda
  • 394
  • 3
  • 14
0

I have observed that UIDocumentPickerController is a subclass of UIViewController Where UIImagepickerController is a subclass of UINavigationController.

if you try to set tintColor of navBar for UIImagePickerController , you can directly access it like imagePicker.navigationBar.tintColor = .red, coming to the document picker, you Cann't access navigationBar directly.you can access it by imagePicker.navigationController?.navigationBar.tintColor = .red. Here navigationController is Optional.thats why we are unable to access navbar directly and make changes.

Apple created an app with document picker. Refer source code here: Particles

Suresh Mopidevi
  • 919
  • 3
  • 9
  • 24