UIDocumentsInteractionController shows iBooks but doesn't open it

My UIDocumentsInteractionController works with what is an action sheet with an β€œiBooks” button, but when I click on this button, it just quits, and that doesn't bring me to iBooks. Here is my code:

NSString *filenamePath =[NSString stringWithFormat:@"temp.%@", [[file path] pathExtension]]; NSString *docDir = [DataCenter getDocumentsDirectoryPath]; NSString *fullPath = [docDir stringByAppendingPathComponent:filenamePath]; NSURL *url = [NSURL fileURLWithPath:fullPath]; UIDocumentInteractionController *c = [UIDocumentInteractionController interactionControllerWithURL:url]; BOOL success = [c presentOpenInMenuFromBarButtonItem:buttonBack animated:YES]; 

What am I doing wrong? Thanks

+4
source share
2 answers

For those stuck with this: you don’t need to configure yourself as a UIDocumentInteractionController delegate at all.

The problem was [UIDocumentInteractionController interactionControllerWithURL:url] auto-implemented. He thought he would be kept inside until an action sheet was shown, but apparently this is not the case. Therefore, yes, you need to save it until the action sheet leaves.

+17
source

Try checking the UIDocumentInteractionControllerDelegate methods documentInteractionController:willBeginSendingToApplication: and documentInteractionController:didEndSendingToApplication: If your view controller is a delegate of the document interaction controller, this should indicate where the problem might be.

In addition, you should verify that the file you are trying to use elsewhere (as I assume the PDF) is actually what you expect from it.

0
source

Source: https://habr.com/ru/post/1402500/


All Articles