UTI 不是包标识符,而是内容的统一类型标识符。
试试下面的
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
如果你需要open,只有菜单的内容会更短,只支持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