UIDocumentInteractionController Delegate

Discussion in 'iOS Programming' started by nashyo, Mar 4, 2012.

  1. nashyo macrumors 6502


    Oct 1, 2010
    -(NSURL*)loadDocument:(NSString*)docName docExtension:(NSString*)docExt
        NSString *path = [[NSBundle mainBundle] pathForResource:docName ofType:docExt];
        return [NSURL fileURLWithPath:path];
    - (IBAction)toolbarActionButtonPressed:(id)sender {
        UIDocumentInteractionController *dIController = [UIDocumentInteractionController interactionControllerWithURL:[self loadDocument:[currentContent objectForKey:@"docName"] docExtension:[currentContent objectForKey:@"docExtension"]]];
        [dIController presentOpenInMenuFromBarButtonItem:sender animated:YES];
    When pressing the toolbarActionButton, an action sheet presents with 1 or more buttons, depending on the device the app is running on (and if apps that support the document are installed). For instance, on my primary device, options to open in iBooks, Adobe Reader, and the Kindle App appear.

    However, when I select any of these action sheet index buttons, the action sheet dismisses and nothing happens.

    Which delegate method do I need to implement to get this working? I understand that the following delegate method is a likely candidate, but how do I call the application identifiers?

    - (void) documentInteractionController: (UIDocumentInteractionController *) controller willBeginSendingToApplication: (NSString *) application {
  2. PhoneyDeveloper macrumors 68040


    Sep 2, 2008
    Have you looked at Apple's DocInteraction sample code?

    FWIW, I use DocInteraction a lot to send files to an app I'm working on. In the Sim, for some reason, DocInteraction stops working after one or two tries. So My app is running in the background. I choose a file and chose Open In my app and nothing happens. To fix it I have to restart my app or the entire Sim. I haven't been able to figure out what the actual problem is but it sounds similar to your description.

Share This Page