1

Possible Duplicate:
UIDocumentInteractionController no longer works in iOS6

I can't open Instagram from my app. Here's the code I'm using:

NSString  *imageToUpload = [NSHomeDirectory() stringByAppendingPathComponent:@"Documents/mapapic-instagram.igo"];
NSData *imageData = UIImageJPEGRepresentation(image, 0.8);
[imageData writeToFile:imageToUpload atomically:YES];

_documentInteractionController 
    = [UIDocumentInteractionController interactionControllerWithURL:[NSURL fileURLWithPath:imageToUpload]];
_documentInteractionController.delegate = self;
_documentInteractionController.UTI = @"com.instagram.exclusivegram";
NSString *defaultInstagramText = @"Hello";

_documentInteractionController.annotation = @{ @"InstagramCaption" : defaultInstagramText };
BOOL success = [_documentInteractionController presentOpenInMenuFromRect:CGRectZero 
                                                                  inView:self.view.window
                                                                animated:YES];

The last call returns YES. Yet nothing happens, and Instagram is not opened. The UIDocumentInteractionControllerDelegate methods are not called. I have the Instagram app installed. What am I doing wrong?

Community
  • 1
  • 1
TotoroTotoro
  • 17,524
  • 4
  • 45
  • 76

1 Answers1

1

Here's what I needed to change to make it work (changing self.view.window to self.view in the call below).

BOOL success = [_documentInteractionController presentOpenInMenuFromRect:CGRectZero 
                                                                  inView:self.view.window
                                                                animated:YES];

Apparently the behavior of UIDocumentInteractionController presentOpenInMenuFromRect:inView:animated was changed in iOS 6, which broke my code, which used to work before. I'll later test this change in iOS 5 to see if it still works there.

TotoroTotoro
  • 17,524
  • 4
  • 45
  • 76