UIDocumentInteractionController在iOS 8中被破坏 [英] UIDocumentInteractionController broken in iOS 8

查看:169
本文介绍了UIDocumentInteractionController在iOS 8中被破坏的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我为iOS 7构建时,下面的相关代码工作得很好,但现在似乎在iOS 8中,它无法正常工作。

The related code below worked perfect when i was building for iOS 7, but it seems now in iOS 8, it's not working properly.

正确地说,我的意思是在某种意义上,它实际上并没有将文件或其他内容发送到所选择的应用程序。

By properly, I mean in the sense where it's not actually sending the file or whatever to the chosen app.

示例:如果我选择了Mail,它将打开带有图像或zip的邮件应用程序我在文本字段中选择了。现在它不会发送,并且需要永远调用/解除UIDocumentInteractionController。

Example: If I selected Mail, it would open the mail app with the image or zip I chose in the text field. Now it won't send and it takes forever to call/dismiss the UIDocumentInteractionController.

我做错了什么?

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    [self.tableView deselectRowAtIndexPath:indexPath animated:NO];

    NSString *fileName = [directoryContents objectAtIndex:indexPath.row];
    NSString *path;
    NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
    path = [[paths objectAtIndex:0] stringByAppendingPathComponent:@"Downloads"];
    path = [path stringByAppendingPathComponent:fileName];


    documentController = [[UIDocumentInteractionController alloc] init];
    documentController = [UIDocumentInteractionController interactionControllerWithURL:[NSURL fileURLWithPath:path]];
    [documentController setDelegate:self];
    [documentController presentOptionsMenuFromRect:CGRectZero inView:self.view animated:YES];
    [documentController retain];

}


推荐答案

我有一直在玩 UIDocumentInteractionController 和Delegate尝试修复类似问题,控制器打开正常但是选择一个应用程序导致它关闭而不做任何事情,我的委托方法 documentInteractionControllerDidDismissOpenInMenu 之后也运行正常。

I have been playing around with the UIDocumentInteractionController and Delegate trying to fix a similar problem, the controller opened-up alright but selecting an application caused it to close without doing anything, my delegate method documentInteractionControllerDidDismissOpenInMenu also run alright afterwards.

在控制台中我收到通知在iOS 8.0中不支持enabledRemoteNotificationTypes后来。

In the console i got the notification enabledRemoteNotificationTypes is not supported in iOS 8.0 and later.

事实证明,当调用其中一个委托方法时,会出现此问题:

It turns out that this problem will accrue when one of these delegate methods is called :

documentInteractionControllerDidDismissOpenInMenu
documentInteractionControllerDidDismissOptionsMenu

(和可能是其他人,我没有检查所有这些)

(and possibly others, i did not check all of them)

我没有在 IOS开发库 UIDocumentInteractionController.h 关于IOS 8.1不支持的这些方法,但此时我无法找到任何其他解释。

I did not find any comment in the IOS Development Library or the UIDocumentInteractionController.h about these methods not supported for IOS 8.1 but at this point i cant find any other explanation.

我更换了 documentInteractionControllerDidDismissOpenInMenu
didEndSendingToApplication
它解决了我的问题。

i replaced documentInteractionControllerDidDismissOpenInMenu with didEndSendingToApplication and it solved the problem for me.

这篇关于UIDocumentInteractionController在iOS 8中被破坏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆