- android - RelativeLayout 背景可绘制重叠内容
- android - 如何链接 cpufeatures lib 以获取 native android 库?
- java - OnItemClickListener 不起作用,但 OnLongItemClickListener 在自定义 ListView 中起作用
- java - Android 文件转字符串
我正在 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
绑定(bind)到 IB 中的一个按钮。当我点击它时,它会打开 iCloud 浏览器,但其中的每个文件夹都是灰色的(我创建了一些测试 Keynote、Numbers 和 Pages 文件)所以我无法访问这些文件:
.
我检查了一些文档并做了以下(没有运气):
在我的 Info.plist 中添加了 public.data
的 UTI,如下所示:
<key>CFBundleDocumentTypes</key>
CFBundleTypeIconFile 图标.png CFBundleType名称 我的数据 CFBundleTypeRole 查看器 LSItemContentTypes 公共(public)数据 LSTypeIsPackage NS文档类 文档 NSPersistentStoreTypeKey 二进制
将值为 YES
的 NSUbiquitousContainerIsDocumentScopePublic
键添加到我的 Info.plist。
知道哪里有问题或遗漏了什么吗?
最佳答案
**Swift 3+ Solution**
将打开并提供对驱动器上所有项目的访问权限。
//open document picker controller
func openImportDocumentPicker() {
let documentPicker = UIDocumentPickerViewController(documentTypes: ["public.item"], in: .import)
documentPicker.delegate = self
documentPicker.modalPresentationStyle = .formSheet
self.present(documentPicker, animated: true, completion: { _ in })
}
/*
*
* Handle Incoming File
*
*/
func documentPicker(_ controller: UIDocumentPickerViewController, didPickDocumentAt url: URL) {
if controller.documentPickerMode == .import {
let alertMessage: String = "Successfully imported \(url.absoluteURL)"
}
}
/*
*
* Cancelled
*
*/
func documentPickerWasCancelled(_ controller: UIDocumentPickerViewController) {
print("Cancelled")
}
关于ios - UIDocumentPickerViewController - 所有文件变灰,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24497213/
这是我打开文档选择器的方式 func openDocuments(){ let documentPicker = UIDocumentPickerViewController(docu
我正在编写一个 iOS 应用程序,我希望能够查看 iCloud 驱动器中的所有文件。我已经使用以下 UTI 数组设置了 UIDocumentPickerViewController: ["\(kUTT
我正在开发一个应用程序,它能够从其他提供 UIDocumentPickerViewControllerExtenstion 来选择文件的云资源导入音频文件,但我想删除它的左上角有一个位置按钮。 下面是
我在 iOS 8 上使用 UIDocumentPickerViewController 允许用户打开 iCloud Drive 中的文档。 我将 UIDocumentPickerModeOpen 与我
我将 UIDocumentPickerViewController 与导入模式 (UIDocumentPickerModeImport) 结合使用,以便让用户从云存储提供商(保管箱等)导入文档。每次用
我正在 iOS 8 中测试新的 UIDocumentPickerViewController API。我只想在 iCloud 中打开一个文件,看看交互是如何工作的。 这是我从我的 UIViewCont
我想从 Google Drive 和 One Drive 云服务中选择文件,为此我正在使用 UIDocumentPickerViewController 例如: func didPressOneDri
我的应用使用带有白色按钮和文本的红色导航 (2) 栏。当我使用系统联系人选择器 (3) 时,状态栏为红色。当我使用文档选择器 (1) UIDocumentPickerViewController 时,
我在我的 iOS 中使用 UIDocumentPickerViewController,它有时会崩溃。只是 View Controller 崩溃了;该应用程序本身很好。我在 Pages 中也注意到了这
我想将我的 DocumentPicker 的导航栏背景颜色设置为与我的应用程序的其余部分相同。 let filePicker = UIDocumentPickerViewController(
我想将文档导入到我的应用程序中。我创建了一个演示来导入文档。演示正在运行。下面是打开UIDocumentPickerViewController的Demo代码。 -(IBAction) btnOpen
我指的是用于文档提供程序扩展的 WWDC 2014 示例应用程序 NewBox。我正在使用 NeBox 应用程序中的以下代码,将文档从文档提供程序导入我的应用程序。 - (void)documentP
在我的应用程序中,我使用 UIDocumentPickerViewController 来允许用户选择文件(导入),但从 iOS 13 开始该功能停止工作,基本上文档选择器是打开的,但用户可以' t
我正在尝试使用 UIDocumentPickerViewController 从文件应用程序中选择文件,但我看不到用于在选择器中进行多项选择的 Select 按钮。为什么会这样?我做错了什么吗?谁能帮
是否可以使用 UIDocumentPickerViewController 来允许用户选择多个文件以从另一个应用程序导入? 最佳答案 使用以下代码片段,这将在标题旁边添加“选择”按钮,以一次选择多个文
我正在尝试访问第三方云应用程序。我的应用程序上传按钮单击打开 UIDocumentPickerViewController 并需要选择文件(单个或多个),然后我上传我的服务器。 上传按钮点击UIDoc
我的应用程序在运行时会在其文档目录中创建一个 json 文档(使用 UIDocument 子类)。然后,当打开 UIDocumentPickerViewController 选择文件时,如果应用程序写
为了能够从应用程序访问 iCloud Drive,我认为我们想从应用程序中使用 UIDocumentPickerViewController。但我在使用 UIDocumentPickerViewCon
在我的应用程序中,我的 UIDocumentPickerViewController 的框架大小始终全屏,如下图和以下代码所示。但是,我发现 UIDocumentPickerViewControlle
我正在使用 UIDocumentPickerViewController 将图像导出到 iOS 11 中的文件应用程序。选择器出现,我可以为文件选择一个目的地。我收到文件已移动的回调,我可以在文件中看
我是一名优秀的程序员,十分优秀!