我正在测试iOS 8中的新UIDocumentPickerViewController
API。我想打开iCloud中的一个文件,以便查看交互如何工作。
这是我从UIViewController
运行的代码:
- (IBAction)openDocument:(id)sender {
[self showDocumentPickerInMode:UIDocumentPickerModeOpen];
}
- (void)showDocumentPickerInMode:(UIDocumentPickerMode)mode {
UIDocumentPickerViewController *picker = [[UIDocumentPickerViewController alloc] initWithDocumentTypes:@[(NSString *)kUTTypeData] inMode:mode];
picker.delegate = self;
[self presentViewController:picker animated:YES completion:nil];
}
openDocument
与IB中的按钮绑定。当我点击它时,它会打开iCloud浏览器,但其中的每个文件夹都是灰色的(我创建了一些测试Keynote、Numbers和Pages文件),所以我无法访问这些文件:
.
我查看了一些文档并尝试了以下操作(但没有成功):
- Enabled iCloud in my app (in the Capabilities section, for both Key-value storage and iCloud Documents).
Added the UTI for
public.data
in my Info.plist as follows:<key>CFBundleDocumentTypes</key>
CFBundleTypeIconFile icon.png CFBundleTypeName MyData CFBundleTypeRole Viewer LSItemContentTypes public.data LSTypeIsPackage NSDocumentClass Document NSPersistentStoreTypeKey Binary
Added the
NSUbiquitousContainerIsDocumentScopePublic
key with a value ofYES
to my Info.plist.