问题 UIDocumentInteractionController不再适用于iOS6


我有一个应用程序与Instagram共享为iOS5和现在在iOS6,共享不再工作,但 canOpenURL 返回true并执行代码。使用a将图像保存到应用程序的文档文件夹中 .igo 延期。这是通过com.instagram.exclusivegram传递给Instagram的。

代码如下,它进入if语句并显示“here in”但不会像屏幕底部那样打开Share With对话框。

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

谢谢, 缺口


11228
2017-09-27 23:21


起源



答案:


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

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

我测试了这个,它将解决问题。


11
2017-10-14 22:33



谢谢你我想出来了,忘了发帖!好的发现 - Nick Pirollo
谢谢你的作品。但有没有办法直接进入Instagram,没有动作表“打开”? - GeneCode


答案:


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

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

我测试了这个,它将解决问题。


11
2017-10-14 22:33



谢谢你我想出来了,忘了发帖!好的发现 - Nick Pirollo
谢谢你的作品。但有没有办法直接进入Instagram,没有动作表“打开”? - GeneCode


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


0
2017-11-16 16:54