gpt4 book ai didi

ios - UIDocumentInteractionController 不显示基于 UTI 的应用程序

转载 作者:行者123 更新时间:2023-12-03 21:14:11 26 4
gpt4 key购买 nike

我想在 iBooks 应用程序中读取 .epub 文件,所以我使用 UIDocumentInteractionController 在 iBooks 中打开 .epub 文件。一切正常,但我只想在 UIDocumentInteractionController 中显示 iBooks 应用程序而不是其他应用程序,所以我为 iBooks 添加了 UTI但它仍然显示下面的所有应用程序都是我的代码。

 var sharingController = UIDocumentInteractionController()
sharingController.url = url
sharingController.uti = "com.apple.iBooks"
sharingController.name = url.lastPathComponent
sharingController.presentOptionsMenu(from: view.frame, in: view, animated: true)

最佳答案

UTI 不是 bundle 标识符,而是内容的统一类型标识符

尝试以下操作

sharingController.uti = "org.idpf.epub-container"

或使用 MobileCoreServices 中的常量

import MobileCoreServices

...
sharingController.uti = kUTTypeElectronicPublication as String

更新: 顺便说一句,上面提供的(和其他)选项不会限制所记录的调用选项对话框(见下文),因为它确定所有应用程序都能够快速查看、复制、打开文件等

// This is the default method you should call to give your users the option to quick look, open, or copy the document.
// Presents a menu allowing the user to Quick Look, open, or copy the item specified by URL.
// This automatically determines the correct application or applications that can open the item at URL.
// Returns NO if the options menu contained no options and was not opened.
// Note that you must implement the delegate method documentInteractionControllerViewControllerForPreview: to get the Quick Look menu item.
open func presentOptionsMenu(from rect: CGRect, in view: UIView, animated: Bool) -> Bool

如果您需要打开,则菜单内容会更短,仅针对支持epub的读者。

// Presents a menu allowing the user to open the document in another application.  The menu
// will contain all applications that can open the item at URL.
// Returns NO if there are no applications that can open the item at URL.
open func presentOpenInMenu(from rect: CGRect, in view: UIView, animated: Bool) -> Bool

关于ios - UIDocumentInteractionController 不显示基于 UTI 的应用程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61797538/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com