I found a glitch on my app on iOS/iPadOS 16.1. The directory to open files is not saved. I filed this on Feedback Assistant but Apple says that it is a specified behavior. Isn't it a bug?
//
// ViewController.m
//
#import "ViewController.h"
#import <UniformTypeIdentifiers/UniformTypeIdentifiers.h>
@interface ViewController () <UIDocumentPickerDelegate>
@end
@implementation ViewController
{
NSURL *directoryURL;
}
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view.
}
- (void)documentPicker:(UIDocumentPickerViewController *)controller didPickDocumentsAtURLs:(NSArray<NSURL *> *)urls
{
directoryURL = [[urls firstObject] URLByDeletingLastPathComponent];
}
- (IBAction)trigger:(id)sender
{
UIDocumentPickerViewController *picker = [[UIDocumentPickerViewController alloc] initForOpeningContentTypes:@[UTTypeData] asCopy:NO];
picker.directoryURL = directoryURL;
[self presentViewController:picker animated:YES completion:nil];
}
@end
To reproduce the issue.
- Tap the button and select a file on another directory.
- Tap the button again.
- The directory should be the selected one but is the default one.