Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

UIDocumentsInteractionController shows iBooks but doesn't open it

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

like image 570
0xSina Avatar asked Dec 01 '22 23:12

0xSina


1 Answers

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.

like image 71
0xSina Avatar answered Dec 24 '22 18:12

0xSina