UIDocumentInteractionController 在 iOS6 中不再工作



我有一个应用程序,它与为 iOS5 构建的 Instagram 共享,现在在 iOS6 中,尽管canOpenURL返回 true 并且代码执行,但共享不再有效。 图像将保存到应用程序的扩展名.igo文件夹中。 这被传递给instagram与com.instagram.exclusivegram。

代码如下,它输入 if 语句并显示"here in",但没有像以前在屏幕底部那样打开"共享"对话框。

        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也提供了正确的文件路径。

谢谢Nick

刚刚做了一些测试并找到了解决方案。不要出现在密钥窗口中。

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

我已经对此进行了测试,它将解决问题。

uidocument交互控制器在 iOS6 中不起作用的另一个原因是现在使用了新的操作表/启动面板(它显示可用于打开文档的应用程序)。我的应用程序在使用 iOS5 启动 iBooks 时运行良好失败,因为我从 viewDidLoad 启动,现在还为时过早,我在当前视图控制器上收到错误"其视图不在窗口层次结构中",所以我在延迟 1 秒后将我的代码更改为执行选择器。该应用程序现在通过新面板调用iBooks。

最新更新