I'm using UIDocumentPickerViewController
on iOS 8 to allow users to open documents in iCloud Drive.
I use UIDocumentPickerModeOpen
with the custom UTI of my app's document:
UIDocumentPickerViewController *pickerViewController = [[UIDocumentPickerViewController alloc]
initWithDocumentTypes:@[[MySampleDocument documentUTI]]
inMode:UIDocumentPickerModeOpen];
pickerViewController.delegate = self;
[self presentViewController:pickerViewController animated:YES completion:^{
}];
This works fine at first. The documents of my app show, the user can pick a document, and it gets opened in the app.
However, if I then use the document picker a second time, the same document that I just picked is now grayed out and cannot be picked again.
Why is that?
The document is still grayed out even after I quit the app. I even deleted the app and installed it again. The document is still grayed out.
I'm using UIDocument so starting and stopping security scoped access is take care of.
I finally figured this out. The document UTI in my Info.plist had to conform to public.data
. Once I added this, the entries are not grayed out anymore.
Another positive side effect is that the kMDItemContentType
of NSMetadtaQuery results now finally show the correct UTI and not dyn.abc1234...
anymore.
Here is the updated and working type definition:
<key>UTTypeConformsTo</key>
<array>
<string>public.composite-content</string>
<string>public.data</string> ← This part was missing before.
</array>