问题标签 [uidocumentbrowservc]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
1 回答
754 浏览

swift - 带有 UTI 的 UIDocumentBrowserViewController 错误

我使用 UIDocumentViewController(来自 Xcode 9 模板)为 iOS 11 创建了一个应用程序。我注册了支持 .swift 文件(public.swift-script)的文档类型,它可以与 open in place 和 Files 应用程序一起使用,但是在应用程序的浏览器中,带有 .swift 扩展名的文件被禁用,我无法选择它们。

我不知道是 iOS 11 的错误还是我,因为如果我将文档类型设置为使用 public.item 文件,它就可以工作。

注意:如果我允许选择多个项目,也会发生同样的事情,但是如果我单击“全选”,则文件会被正常选择。

0 投票
5 回答
2534 浏览

cocoa-touch - Having Trouble Getting the UIDocumentBrowserController to open docs in a Document based app

I've been working on a new Document-based app, and was super glad about the new UIDocumentBrowserController...trying to roll my own solution for the document browser UI was tricky!

I'm having some trouble getting the browser to open documents after they've been created.

What happens now is that when I choose to create a new document in the document browser, the document is created and opened as expected, although an error message is logged. However, after the doc is closed, I cannot reopen the file, either immediately or upon subsequent launches, even though the document is displayed. However, a weird clue here is that if I stop running the app after creating the document, but without adding new information to it (triggering the save cycle), and run the project again, I can open the file correctly. Whuch makes me think that there's something in the way the files are being saved that is the issue. (Note: At this phase, I'm working on getting the local, non/icloud implentation working, before I move on to the icloud implementation.)

Here is the error message at any point in the code whenthe document is saved to disk (or at least most of the time!): 2017-06-20 13:21:58.254938-0500 Sermon Design 2 iOS[22454:5000138] [default] [ERROR] Could not get attribute values for item file:///Users/stevenhovater/Library/Developer/CoreSimulator/Devices/9A4364F2-B3A1-4AD9-B680-FB4BC876C707/data/Containers/Data/Application/DD534ED8-C4A3-40FE-9777-AED961976878/Documents/Untitled-9.sermon. Error: Error Domain=NSFileProviderInternalErrorDomain Code=1 "The reader is not permitted to access the URL." UserInfo={NSLocalizedDescription=The reader is not permitted to access the URL.}

I suspect that the issue lies somewher in my document types plists, which I've tried to set up by imitating the setup in the video for wwdc 2017 session 229.

enter image description here My docs are encapuslated by an NSData object, using what I take to be a pretty standard subclass implentation of UIDocument. (I'm omitting the code to generate the thumbnails)

In my subclass of UIDocumentBrowserViewController, Here is my code for getting a local filename and for creating the new document.

0 投票
1 回答
356 浏览

xcode9-beta - How do you create a new document using UIDocumentBrowserViewController in Xcode 9 beta 2?

I am having problems with UIDocumentBrowserViewController Bug in Xcode 9 Beta 2, was working with beta 1.

The symptom is that you can't create a new document, on most pages the + icon is missing or greyed out. On the browse page it is present and not greyed out, but doesn't work.

EG If you start a new Documents project and modify the function below to include the print statement given:

Then the print statement isn't printed when + on browse page is tapped. Testing on iPad Pro 12" (original) with latest iOS 11 beta.

Is this a bug? Am I doing something wrong?

Thanks for any help,

-- Howard.

0 投票
3 回答
7100 浏览

ios - 使用 UIDocumentBrowserViewController 创建文档

文档documentBrowser(_:didRequestDocumentCreationWithHandler:)说:“创建一个新文档并将其保存到临时位置。如果您使用UIDocument子类创建文档,则必须在调用importHandler块之前关闭它。”

所以我通过获取用户临时目录 ( FileManager.default.temporaryDirectory) 的 URL 并附加名称和扩展名来创建一个文件 URL 4166-B137-5B43185169D8/tmp/Untitled.uti")。但是当我调用save(to:for:completionHandler:)传递这个 URL 时,完成处理程序永远不会被回调。我还尝试使用url(for:in:appropriateFor:create:)传递用户临时目录中的子目录——完成处理程序仍然没有被调用。

我了解文档浏览器视图控制器由一个单独的进程管理,该进程具有自己的读/写权限。除此之外,我很难理解问题所在。新文档可以临时保存在哪里,以便文档浏览器进程可以移动它们?

更新:在当前的测试版中,我现在看到域NSFileProviderInternalErrorDomain和代码1被记录的错误:“不允许读者访问 URL。” 至少这是对正在发生的事情的确认……</p>

0 投票
3 回答
1316 浏览

ios11 - UIDocumentBrowserViewController 为空

我正在使用UIDocumentBrowserViewController. 一切正常(位置和文件出现,可创建,可选择)

突然间,文档浏览器显示为空。没有地点,没有文件……</p>

在此处输入图像描述

在今天之前,浏览器在模拟器中是空的,但在设备上运行良好。现在,他的问题“迁移”到了我的 iPad 上。我认为这是一个测试版问题,但如果有其他人遇到同样的问题,是否已经设法找到修复/解决方法,我将不胜感激?

试过了……</p>

  • 干净的构建
  • 删除模块缓存/派生数据
  • 删除/重新安装应用程序
  • 重启 Xcode
  • 重新启动 iPad
  • 重新安装 Xcode
  • 重新启动 Mac

我开始认为我在想象它在过去有效!

Xcode 9.0 测试版 4 (9M189t)


更新

我刚刚发现使用

而不是我的自定义 UTI 作品。然后再次恢复到我自己的 UTI仍然有效。

0 投票
1 回答
532 浏览

ios - UIDocumentPickerModeExportToService 在 iOS11 中不显示 Drive 或 DropBox

我一直在我的应用程序中使用 UIDocumentMenuViewController 和 UIDocumentPickerViewController 从 Google Drive、DropBox、iCloud 等 3rd 方应用程序导入图像和 pdf。这也用于将一些 pdf 从我的应用程序导出到这些其他应用程序。在最新的 iOS 更新之前,它工作正常。

在 iOS 11 中,导入服务按预期工作,但在我尝试导出 pdf 的应用程序中,该应用程序只显示“iCloud Drive”和“在我的 iPhone 上”选项。它不显示 Google Drive 或 DropBox。此行为特定于 iOS 11。

我在 Apple 上阅读了有关 UIDocumentMenuViewController、UIDocumentPickerViewController 和 UIDocumentBrowserViewController 的文档。他们都没有为 iOS11 中的“UIDocumentPickerModeExportToService”模式指定任何更改。我是否缺少来自 Apple 的任何更新信息?

更新:Dropbox 和 Google Drive 发布了与 iOS11 兼容的新版本应用程序。将这些应用程序更新到新版本即可解决问题!

0 投票
0 回答
232 浏览

ios - 如何将 DropBox 或 Google Drive 上的已编辑文件与基于文档的应用程序 ios 同步

我正在开发一个基于文档的应用程序 ios 11 swift 4 的应用程序。

importHandler我可以在DropBox 或 Google Drive 上借助UIDocumentBrowserViewControllerDelegate.

我可以编辑这些文档并将它们保存在 DropBox 或 Google Drive 的本地共享目录中。但是文件没有与各自的云控制台同步。

这适用于 iCloud。

不明白 DropBox 或 Google Drive 同步过程有什么问题。

请帮助我找到解决方案。

0 投票
1 回答
617 浏览

ios - 没有 iCloud 的 UIDocumentBrowserViewController

苹果表示,为了在 Files 应用中显示你应用的文档,你的Info.plist一方面必须开启“支持文档浏览器”,或者“应用支持 iTunes 文件共享”和“支持就地打开文档”,在另一个。

但是出于好奇,我尝试将它们全部打开,并且成功了。我的测试应用程序是基于文档浏览器的,但它可以在其 Documents 文件夹以及 iCloud 中保存(和浏览)文档。即使用户关闭了 iCloud Drive,从这个意义上说,我的应用程序仍然可以正常工作。

我的问题(相当模糊)是:这合法吗?苹果让这两种方法看起来相互排斥,但它们实际上兼容吗?有没有人写过一个严肃的应用程序,在Info.plist 中打开了所有这三个选项,以便从应用程序自己的文件浏览器中浏览应用程序自己的本地文档?

0 投票
0 回答
766 浏览

swift - UIDocumentBrowserViewController 处理返回导航

Apple 声明 UIDocumentBrowserViewController 应该是应用程序的 rootviewcontroller。 https://developer.apple.com/documentation/uikit/view_controllers/adding_a_document_browser_to_your_app

我已经这样做了,但是我有一些我无法解决的用户体验问题。我找不到一个好的 UX 解决方案来导航回我的应用程序(再次将应用程序窗口 rootviewcontroller 切换回我想要的任何内容)。

但是我发现有一些属性可以在其中操纵控件的外观,“使用 additionalLeadingNavigationBarButtonItems 和 additionalTrailingNavigationBarButtonItems 方法将按钮添加到导航栏。”,但这些不会将项目添加到“主”菜单(我可以选择其他 FileProviders、驱动器保管箱等)以及返回的可能性是最清楚的。

有没有人实施过,知道添加后退按钮、FAB、后退滑动手势或 UIDocumentBrowserViewcontroller 的东西的好解决方案,它在应用程序 rootviewcontroller 中呈现?

当用户结束浏览 UIDocumentBrowserViewcontroller(复制、导入等)中的文档并想要返回另一个 Viewcontroller 时,我正在寻找解决方案。

0 投票
1 回答
381 浏览

ios - UIDocumentBrowserViewController 获取文件数据

当我使用 UIDocumentBrowserViewController 并获取文件的 documentURL 时,例如“file:///private/var/mobile/Containers/Data/Application/8F45C0E0-446B-4C89-A7AB-95E148BE0F41/Documents/sd1513175706_2.MP4”,我使用 [ NSData dataWithContentsOfFile] 来获取数据,但它不起作用。有什么问题 ?