JUCE icon indicating copy to clipboard operation
JUCE copied to clipboard

handle canSelectDirectories in iOS native FileChooser

Open faqteur opened this issue 2 years ago • 2 comments

Use canSelectDirectories flag in iOS native FileChooser

faqteur avatar Apr 26 '22 15:04 faqteur

My initial try-out with this does not give the expected results. The file browser view changes from Icons to List (that I can't change to Icons view anymore) and the files are not displayed; only directories. I'm initializing like this:

typedef juce::FileBrowserComponent flags;
auto chooserFlags = flags::canSelectFiles |
    flags::canSelectDirectories |
    flags::canSelectMultipleItems |
    flags::openMode;fileChooser->launchAsync(
        chooserFlags, [&_mpc](const juce::FileChooser &chooser) { /* do stuff */ }

izzyreal avatar Sep 18 '22 15:09 izzyreal

Been playing a bit in an Objective C playground app and with UIDocumentBrowserViewController I get the desired result -- I can select multiple files and directories using this code:

#import "ViewController.h"

#include <CoreServices/UTType.h>
#import <UniformTypeIdentifiers/UniformTypeIdentifiers.h>

@interface ViewController ()
@end

@implementation ViewController

- (void)viewDidAppear:(BOOL)animated {
  NSArray *utis = @[ (NSString *)UTTypeItem ];
  UIDocumentBrowserViewController *picker =
    [[UIDocumentBrowserViewController alloc] initForOpeningContentTypes:utis];
  [self presentViewController:picker animated:YES completion:nil];
}

@end

The same code with UIDocumentPickerViewController reproduces JUCE's behaviour.

izzyreal avatar Sep 18 '22 16:09 izzyreal