Sudheesh
Sudheesh

Reputation: 473

Open Instagram only in UIDocumentInteractionController

My application required to post an image to Instagram, I used UIDocumentInteractionController to open image file saved in the Documents directory with an extension .igo. Set com.instagram.exclusivegram as the UIDocumentInteractionController's UTI property. That all worked fine, my problem is that when I use

[dic presentOpenInMenuFromRect:CGRectZero inView:self.view animated:YES];

to open the UIDocumentInteractionController, it shows PDF reader, DropBox etc. I have to hide the other options than Instagram or show Instagram only. And also how to identify the Cancel button press in the presented menu.

Upvotes: 3

Views: 1507

Answers (1)

Cheng-Yu Hsu
Cheng-Yu Hsu

Reputation: 1049

  1. Why is my UIDocumentInteractionController showing other options?

    If you're using some code snippet from the Internet, make sure you implemented the delegate method correctly.

    -(UIDocumentInteractionController *)setupControllerWithURL:(NSURL *)fileURL 
                                                 usingDelegate:(id<UIDocumentInteractionControllerDelegate>) interactionDelegate 
    {
        // if you're creating a new instance here,
        // make sure you set the properties correctly
        UIDocumentInteractionController *interactionController = [UIDocumentInteractionController interactionControllerWithURL:fileURL];
        // remember to set it again here
        interactionController.UTI = @"com.instagram.exclusivegram";
        interactionController.delegate = interactionDelegate;    
        return interactionController;
    } 
    
  2. How can I know if a user cancel the action or proceed to Instagram?

    Please refer to the answer of this thread: UIDocumentInteractionController Open Menu Cancelled Callback.

Upvotes: 1

Related Questions