我想在iBooks App中打开特定文件。我使用UIDocumentsIntractionController将此文件发送到iBooks App。我的代码:
class ViewController : UIViewController {
...
...
@IBOutlet var iBooksBtn: UIButton!
@IBAction func book(sender: AnyObject) {
let ibookPath = NSBundle.mainBundle().pathForResource("test1",ofType: "ibooks")!
interactionController = UIDocumentInteractionController(URL: NSURL(fileURLWithPath:ibookPath))
interactionController.UTI = "com.apple.ibooks"
interactionController.presentOpenInMenuFromRect(CGRectZero,inView:self.iBooksBtn, animated:false)
}
...
...
}
所以,现在我将此文件存储在mainBundle中,但将来我想从Internet下载它。所以,当我按下按钮时,我得到的结果很少 中选择:
但我想只使用iBooks打开此文件,而无需选择App(如图所示)。据我所知,我需要使用UTI for * .ibooks文件,我想UTI,我用过的是错误的。谢谢你的帮助。自定义URL方案(ibooks://等)对我不起作用。
答案 0 :(得分:0)
要打开iBooks,您应该使用自定义URL方案:
打开图书馆:
NSString *stringURL = @"ibooks://";
NSURL *url = [NSURL URLWithString:stringURL];
[[UIApplication sharedApplication] openURL:url];
要在特定的书页上打开iBooks商店,您必须将完整的URL添加到该特定的书中:
NSString *stringURL = @"itms-books://itunes.apple.com/de/book/marchen/id436945766";
NSURL *url = [NSURL URLWithString:stringURL];
[[UIApplication sharedApplication] openURL:url];
NSString *stringURL = @"itms-bookss://itunes.apple.com/de/book/marchen/id436945766";
NSURL *url = [NSURL URLWithString:stringURL];
[[UIApplication sharedApplication] openURL:url];