Crazy Developer
Crazy Developer

Reputation: 3464

Buttons not visible in UIDocumentPickerViewController

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

Upvotes: 5

Views: 1588

Answers (2)

Willeminna
Willeminna

Reputation: 1

For Objective C:

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

[[UINavigationBar 
    appearanceWhenContainedInInstancesOfClasses:
      @[[UIDocumentBrowserViewController class]]] setTintColor: nil];

Upvotes: 0

Antoine Lamy
Antoine Lamy

Reputation: 883

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
}

Upvotes: 7

Related Questions