I am trying to use the iOS file picker to select text files but when I instantiate and present (modally) a UIDocumentMenuViewController
or a UIDocumentPickerViewController
the UI takes a while to show up.
This is the code I tried to use for the UIDocumentMenuViewController
the one for the UIDocumentPickerViewController
would be fairly similar:
UIDocumentMenuViewController *menuVC = [[UIDocumentMenuViewController alloc] initWithDocumentTypes:@[(NSString *)kUTTypeText] inMode:UIDocumentPickerModeOpen];
menuVC.delegate = self;
[self presentViewController:menuVC animated:YES completion:nil];
If I try to call this code 3 or more times then the lag disappears. I understand that when working with iCloud documents there are synchronous operations that takes time but I didn't find a way to kind of preload that so by the time I present the view controller it happens instantly. I even tried to instantiate the view controllers much before presenting them, but the initialisation doesn't seam to be the bottleneck.
Did anyone experienced the same problem?