UIDocumentPickerViewController - 如何从iCloud导入/导出文件

时间:2016-01-15 05:51:33

标签: ios objective-c iphone

我搞了它,然后我开始了解如何从iCloud帐户获取文件的过程

- (void)showDocumentPickerInMode:(UIDocumentPickerMode)mode {
UIDocumentPickerViewController *documentPicker = [[UIDocumentPickerViewController alloc] initWithDocumentTypes:@[@"com.apple.iwork.pages.pages", @"com.apple.iwork.numbers.numbers", @"com.apple.iwork.keynote.key"] inMode:mode];

documentPicker.delegate = self;
documentPicker.modalPresentationStyle = UIModalPresentationFormSheet;
[self presentViewController:documentPicker animated:YES completion:nil];
}

- (void)documentPicker:(UIDocumentPickerViewController *)controller didPickDocumentAtURL:(NSURL *)url {
if (controller.documentPickerMode == UIDocumentPickerModeImport) {
    NSString *alertMessage = [NSString stringWithFormat:@"Successfully imported %@", [url lastPathComponent]];
    dispatch_async(dispatch_get_main_queue(), ^{
        UIAlertController *alertController = [UIAlertController
                                              alertControllerWithTitle:@"Import"
                                              message:alertMessage
                                              preferredStyle:UIAlertControllerStyleAlert];
        [alertController addAction:[UIAlertAction actionWithTitle:@"Ok" style:UIAlertActionStyleDefault handler:nil]];
        [self presentViewController:alertController animated:YES completion:nil];
    });
}
}

但是在运行时我收到的警告如下:

  

警告:尝试展示<UIDocumentPickerViewController:> 0x14ed4f2b0>

其视图不在窗口层次结构中!

我无法打开UIDocumentPickerViewController

能否帮我解决一下(如何在Apple帐户中启用iCloud开发证书的权利)&amp;我怎么能解决这个问题 enter image description here

0 个答案:

没有答案