bretto
bretto

Reputation: 71

UIDocumentInteractionController not transferring to target application

My app is generating an image which I'm attempting to pass to Instagram using a document interaction controller and their hook. Oh, this is using iOS 5.1.

I have the UIDocumentInteraction action sheet showing up properly but the issue is that once the user select "open in Instagram" the sheet is dismissed and nothing happens.

The code:

// Method returns a path to the generated image
NSURL *finalCompositePath = [NSURL fileURLWithPath:[self generateFinalImage:@"instagram"]];
UIDocumentInteractionController *documentInteractionController;
NSURL *instagramURL = [NSURL URLWithString:@"instagram://camera"];
if ([[UIApplication sharedApplication] canOpenURL:instagramURL]) {
    //imageToUpload is a file path with .ig file extension
    documentInteractionController = [UIDocumentInteractionController interactionControllerWithURL:finalCompositePath];
    documentInteractionController.UTI = @"com.instagram.exclusivegram";
    documentInteractionController.delegate = self;
    documentInteractionController.annotation = [NSDictionary dictionaryWithObject:@"Caption Test" forKey:@"InstagramCaption"];
    [documentInteractionController presentOptionsMenuFromBarButtonItem:self.ShareButton animated:YES];
}

Thoughts?

Upvotes: 0

Views: 3113

Answers (1)

mylegfeelsfunny
mylegfeelsfunny

Reputation: 507

UIDocumentsInteractionController shows iBooks but doesn't open it has the correct answer for apps using arc. UIDocumentInteractionController must be a property of the class.

BUT ALSO!!!
If you are supporting down to ios5, make sure the image you've saved is a type ".igo" (not .jpg or .png).
IOS6 will open it up in instagram, but IOS less than 6 will just dismiss the UIDocumentInteractionController without proceeding to instagram.

Upvotes: 3

Related Questions