我正在使用附加到按钮的以下代码尝试在 iBooks 中打开 PDF 文件,但是当我单击该按钮时没有任何反应。该方法肯定会被调用。
- (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];
}
我已经将类本身声明为相关的委托(delegate),并且由于文档说没有必需的委托(delegate)方法,所以我已经完成了这些。当我点击按钮时没有任何反应,我正在尝试找出我遗漏了什么 - 非常感谢任何帮助!
最佳答案
如果 MS.pdf 在您的包中,那么您需要像这样获取完整路径:
NSString *path = [[NSBundle mainBundle] pathForResource:@"MS" ofType:@"pdf"];
NSURL *url = [NSURL fileURLWithPath:path];
关于objective-c - 从应用程序内将捆绑的 PDF 发送到 iBooks,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9650263/