UIDocumentInteractionController no longer works in iOS6
Asked Answered
S

2

11

I have an app that shares with instagram built for iOS5 and now in iOS6, sharing no longer works although canOpenURL returns true and code executes. The images are saved to the documents folder of the application with a .igo extension. This is passed to instagram with com.instagram.exclusivegram.

The code is below, it enters the if statement and displays "here in" but does not open the Share With dialog like it used to at the bottom of the screen.

        NSLog(@"%@", _imgToUpload);
        NSURL *instagramURL = [NSURL URLWithString:@"instagram://app"];
        if ([[UIApplication sharedApplication] canOpenURL:instagramURL]) {
            uidController = [[UIDocumentInteractionController alloc] init];
            //imageToUpload is a file path with .igo file extension
            uidController = [UIDocumentInteractionController interactionControllerWithURL:[NSURL fileURLWithPath:_imgToUpload]];
            uidController.UTI = @"com.instagram.exclusivegram";
            uidController.delegate = self;
            CGRect navRect = self.view.frame;
            [uidController presentOpenInMenuFromRect:navRect inView:[UIApplication sharedApplication].keyWindow animated:YES];
            NSLog(@"here in");
        }

_imgToUpload is providing the correct filepath as well.

Thank you, Nick

Sachsen answered 27/9, 2012 at 23:21 Comment(0)
M
11

Just did some testing and found a solution. Do not present in the keyWindow.

[uidController presentOpenInMenuFromRect:navRect inView:self.view animated:YES];

I have tested this and it will fix the problem.

Marcosmarcotte answered 14/10, 2012 at 22:33 Comment(2)
thank you i had figured this out and forgot to post! good findingsSachsen
thanks this works. But is there any way to directly go into Instagram, without the actionsheet "Open In"?Cargill
L
0

Another reason for the uidocumentinteraction controller not working in iOS6 is that the new action sheet/launch panel (it shows apps available to open the doc) is now used. My app which worked fine launching iBooks with iOS5 failed because I launched from viewDidLoad which was now too early and I got an error on the current view controller 'whose view is not in the window hierarchy' so I changed my code to performselector after delay of 1 second. The app now calls iBooks via the new panel.

Layette answered 16/11, 2012 at 16:54 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.