Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
357 views
in Technique[技术] by (71.8m points)

iphone - UIDocumentInteractionController no longer works in iOS6

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

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...