UIDocumentInteractionController在iOS 8中被破坏

时间:2014-10-25 15:43:41

标签: ios8 tableview share cell

当我为iOS 7构建时,下面的相关代码非常完美,但现在似乎在iOS 8中,它运行不正常。

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

示例:如果我选择了Mail,它将打开包含我在文本字段中选择的图像或zip的邮件应用程序。现在它不会发送,并且需要永远调用/解除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];

}

1 个答案:

答案 0 :(得分:2)

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

在控制台中我收到通知 iOS 8.0及更高版本不支持enabledRemoteNotificationTypes。

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

documentInteractionControllerDidDismissOpenInMenu
documentInteractionControllerDidDismissOptionsMenu

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

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

解决方案:

我替换了documentInteractionControllerDidDismissOpenInMenudidEndSendingToApplication 它解决了我的问题。