从应用程序内将捆绑的PDF发送到iBooks [英] Send bundled PDF to iBooks from within app
问题描述
我正在使用下面的代码附加到按钮上,以尝试在iBooks中打开PDF文件,但是当我单击按钮时没有任何反应.该方法肯定被调用.
I'm using the following code attached to a button, to attempt to open a PDF file in iBooks, but nothing's happening when I click the button. The method's definitely being called.
- (IBAction)openDocs
{
NSURL *url = [NSURL fileURLWithPath:@"MS.pdf"];
UIDocumentInteractionController *docController = [[UIDocumentInteractionController alloc] init];
docController = [UIDocumentInteractionController interactionControllerWithURL:url];
docController.delegate = self;
BOOL isValid = [docController presentOpenInMenuFromRect:CGRectZero inView:self.view animated:YES];
}
我已经将类本身声明为相关的委托,并且由于文档说没有必需的委托方法,所以我已经完成了所有事情.当我点击按钮时什么也没有发生,而我正在尝试找出我所缺少的东西–任何帮助将不胜感激!
I've declared the class itself as the relevant delegate, and since the documentation says there are no required delegate methods, that's all I've done. Nothing's happening when I tap the button, and I'm trying to figure out what I'm missing – any help is greatly appreciated!
推荐答案
如果捆绑包中包含MS.pdf,则需要像这样获取完整路径:
If MS.pdf is in your bundle then you need to get the full path like so:
NSString *path = [[NSBundle mainBundle] pathForResource:@"MS" ofType:@"pdf"];
NSURL *url = [NSURL fileURLWithPath:path];
这篇关于从应用程序内将捆绑的PDF发送到iBooks的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!