5

I want to import a document into my application. I have created a Demo to import Document. A demo is working. below is the code of the Demo to open UIDocumentPickerViewController.

-(IBAction) btnOpenClicked{
    UIDocumentPickerViewController *documentPicker = [[UIDocumentPickerViewController alloc] initWithDocumentTypes:[self allowedUTIs] inMode:UIDocumentPickerModeImport];
    documentPicker.delegate = self;

    [self presentViewController:documentPicker animated:true completion:nil];
}

-(NSArray*)allowedUTIs{
    return @[@"public.data",@"public.content",@"public.audiovisual-content",@"public.movie",@"public.audiovisual-content",@"public.video",@"public.audio",@"public.text",@"public.data",@"public.zip-archive",@"com.pkware.zip-archive",@"public.composite-content",@"public.text"];
}

The same code is implemented in my actual project. UIDocumentPickerViewController open and App is able to import file but the issue is that in the actual app I am not able to see any buttons in the header. thought there is action happen but buttons are not visible. Please check screenshot of the Demo and actual app.
enter image description here enter image description here

Faysal Ahmed
  • 7,501
  • 5
  • 28
  • 50
Crazy Developer
  • 3,464
  • 3
  • 28
  • 62

2 Answers2

7

Your app is probably setting a global UINavigationBar tint color appearance. You can just reset the appearance for UIDocumentPickerViewController only by putting this code somewhere in your application:didFinishLaunchingWithOptions: function and the bar buttons will return to their original blue.

if #available(iOS 11.0, *) {
    UINavigationBar.appearance(whenContainedInInstancesOf: [UIDocumentBrowserViewController.self]).tintColor = nil
}
Antoine Lamy
  • 863
  • 10
  • 9
0

For Objective C:

-> by putting this code somewhere in your application:didFinishLaunchingWithOptions:

[[UINavigationBar 
    appearanceWhenContainedInInstancesOfClasses:
      @[[UIDocumentBrowserViewController class]]] setTintColor: nil];
ouflak
  • 2,458
  • 10
  • 44
  • 49