Question

My UIDocumentsInteractionController is working as far as presenting an action sheet with a button that says "iBooks" but when I click on that button, it just dismisses and it doesn't take me to iBooks. Here's 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

Was it helpful?

Solution

For those stuck at this: You don't need to set yourself up as UIDocumentInteractionController's delegate at all.

Problem was [UIDocumentInteractionController interactionControllerWithURL:url] is being autoreleased. It thought it would be retained internally by the action sheet being shown but apparently it's not. So yea, gotta retain it until action sheet dismisses.

OTHER TIPS

Try checking the UIDocumentInteractionControllerDelegate methods documentInteractionController:willBeginSendingToApplication: and documentInteractionController:didEndSendingToApplication:. If your view controller is the delegate of the document interaction controller, that should clue you in to where the problem may be.

Also, you should validate that the file you're trying to use elsewhere (a PDF I assume) is actually a what you expect it to be.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top