简体   繁体   English

通过UIDocumentInteractionController将pdf文件添加到iBooks,但不打开文件

[英]Add pdf file to iBooks by UIDocumentInteractionController but dont open file

I have small code to open pdf file from my application in iBooks using UIDocumentInteractionController. 我有一些小代码可以使用UIDocumentInteractionController在iBooks中的应用程序中打开pdf文件。 It works. 有用。 But i just want to save and add file to iBooks library, not open it immediately, that means when user choose iBooks application from menu, only an alert view will be displayed to notice user that app successfully add to iBooks, not open pdf file, and user still in app. 但是我只想保存文件并将其添加到iBooks库中,而不是立即打开它,这意味着当用户从菜单中选择iBooks应用程序时,只会显示一个警报视图,以通知用户该应用程序已成功添加到iBooks中,而不是打开pdf文件,并且用户仍在应用中。 Any idea for my problem, please helps me, thanks alot Here is my sample code i use to open pdf file in ibook from my app 关于我的问题的任何想法,请帮助我,非常感谢这是我用来从我的应用程序在ibook中打开pdf文件的示例代码

NSURL *url = [NSURL fileURLWithPath:FilePath];
UIDocumentInteractionController *docController = [UIDocumentInteractionController interactionControllerWithURL:url];

docController.delegate = self;
[docController retain];
BOOL isValid = [docController presentOpenInMenuFromRect:CGRectZero inView:self.view animated:YES];
if(isValid){
}

Btw, if there is no way to solve my problem without open ibooks, so is there other ways to back to my application when user read book in ibook without press home button 顺便说一句,如果没有打开的ibook无法解决我的问题,那么当用户在不按主屏幕按钮的情况下在ibook中阅读图书时,还有其他方法可以返回我的应用程序

The way you describe the flow of saving is not the way Apple's API work. 描述保存流程的方式不是Apple API的工作方式。

If you use the UIDocumentInteractionController the PDF you will be send to the app the user selects. 如果使用UIDocumentInteractionController PDF,则会将PDF发送到用户选择的应用程序。 Nothing is done underwater, the file URL is literally send over to the other app. 在水下什么也没做,文件URL实际上就是发送到另一个应用程序的。 This app (ex. iBooks) will the have check the file and save it. 这个应用程式(例如iBooks)将检查档案并储存。 Thus there is nothing you can do to stop it from opening the app. 因此,您无法采取任何措施阻止它打开应用程序。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM