1

I am trying to share a pdf, that I create within the app, with other apps using UIDocumentInteractionController. The same thing was working with UIActivityViewController.

To do that I call - presentOptionsMenuFromRect:inView:animated: method which returns YES but nothing shows up on the screen.

// view is a UIWindow
- (void)openDocumentFromRect:(UIView*)view withURL:(NSURL*)url {
    UIDocumentInteractionController *documentInteractionController = [UIDocumentInteractionController interactionControllerWithURL:url];
    // the following returns YES
    [documentInteractionController presentOptionsMenuFromRect:[view frame] inView:view animated:YES];
}

Any ideas why ?

Lorenzo
  • 3,293
  • 4
  • 29
  • 56
Moumou
  • 1,513
  • 2
  • 18
  • 41
  • What is your `url` ? – Midhun MP Oct 05 '15 at 10:39
  • @MidhunMP url is something like: `file:///Users/[USER]/Library/Developer/CoreSimulator/Devices/[DEVICE]/data/Containers/Data/Application/[APP]/Library/TICKET.pdf` – Moumou Oct 05 '15 at 11:23
  • @MidhunMP This is what I have on an actual device : `file:///var/mobile/Containers/Data/Application/[APP]/Library/GMS-E-TICKET.pdf`. Doesn't change much. You probably just wanted to see if I had the `file://` I guess – Moumou Oct 05 '15 at 13:10
  • Check whether the view frame is correct or for testing a custom specified rect. – Midhun MP Oct 05 '15 at 13:12
  • @MidhunMP The frame is (0, 0, 320, 568)(iPhone5) so it is okay. Is it possible that the view is not displayed on top of all the others ? – Moumou Oct 05 '15 at 13:21
  • 1
    I got the issue, specify a custom frame like (150,150, 320, 568). The issue is the menu controller anchor is in 0,0 and your menu will be out of the view – Midhun MP Oct 05 '15 at 14:21
  • @MidhunMP Nop, still no showing – Moumou Oct 05 '15 at 14:43
  • @MidhunMP I've managed to make it work. Instead of presenting it in `window` I'm presenting it in `window.rootViewController.view` – Moumou Oct 05 '15 at 14:46
  • @MidhunMP Thanks for your help! Any ideas why it wouldn't show up if presented in `window` ? – Moumou Oct 05 '15 at 14:46
  • Why can't you just use `self.view` instead of `window.rootViewController.view` ? – Midhun MP Oct 06 '15 at 06:10
  • @MidhunMP Because `self` doesn't have a `.view`. This is done "outside" of the actual app, in a lib, where I just have access to `window`. – Moumou Oct 06 '15 at 09:01

0 Answers0