質問

I have small code to open pdf file from my application in iBooks using UIDocumentInteractionController. 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. 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

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

役に立ちましたか?

解決

The way you describe the flow of saving is not the way Apple's API work.

If you use the UIDocumentInteractionController the PDF you will be send to the app the user selects. Nothing is done underwater, the file URL is literally send over to the other app. This app (ex. iBooks) will the have check the file and save it. Thus there is nothing you can do to stop it from opening the app.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top