我有一個應用程序來存儲用戶創建的內容與自定義文件(自定義擴展/ UTI),並希望它支持使用UIDocumentPicker的iCloud驅動器。刪除UIDocumentPicker導入/導出與自定義UTI
1. 問題是,一旦文件被導入,它就會變灰,變得無法導入。 嘗試了幾件事情後,我發現問題出在custome UTI上。 如果我只是將文件擴展名更改爲一個知名的文件擴展名,例如pdf,它就可以工作。
我還使用了下面的示例代碼(只是選擇一個文檔,並且什麼都不做)來測試。 如果我選擇一個帶有自定義擴展名的文件,它將在導入一次後變爲灰色。 pdf文件沒有問題 - 我可以一次又一次地導入它們。
我錯過了什麼嗎?
2. 另一個問題是,如果我將文檔類型指定爲@「public.composite-content」,我可以在根中選擇一個pdf文檔,但不能訪問包含pdf文件的文件夾。如果我使用kUTTypePDF,我可以做到這一點。 這是預期的行爲,還是隻是一個錯誤?
-(void)openDocumentPicker
{
UIDocumentPickerViewController *vc = [[UIDocumentPickerViewController alloc] initWithDocumentTypes:@[@"public.composite-content"] inMode:UIDocumentPickerModeImport];
vc.delegate = self;
vc.modalPresentationStyle = UIModalPresentationFormSheet;
[self presentViewController:vc animated:YES completion:nil];
}
- (void)documentPicker:(UIDocumentPickerViewController *)controller didPickDocumentAtURL:(NSURL *)url {
return;
}