Reputation: 3203
I want to read .epub file in iBooks apps so I am using UIDocumentInteractionController to open.epub file in iBooks .Everything is working fin but I want to show only iBooks app instead of other apps in UIDocumentInteractionController so I added UTI for iBooks but still its display all the app below is my code.
var sharingController = UIDocumentInteractionController()
sharingController.url = url
sharingController.uti = "com.apple.iBooks"
sharingController.name = url.lastPathComponent
sharingController.presentOptionsMenu(from: view.frame, in: view, animated: true)
Upvotes: 2
Views: 600
Reputation: 257701
UTI is not bundle identifier, but uniform type identifier of content.
Try the following
sharingController.uti = "org.idpf.epub-container"
or using constant from MobileCoreServices
import MobileCoreServices
...
sharingController.uti = kUTTypeElectronicPublication as String
Update: btw as provided above (and other) option do not limit the called option dialog as documented (see below), because it's determined all applications capable to quick look, copy, open, etc for the file
// 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
if you'd need to open
only the content of menu would be more short, only to readers supported 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
Upvotes: 1