4

我的 UIDocumentsInteractionController 正在工作,只要显示一个带有“iBooks”按钮的操作表,但是当我单击该按钮时,它只是关闭并且它不会带我到 iBooks。这是我的代码:

NSString *filenamePath =[NSString stringWithFormat:@"temp.%@", [[file path] pathExtension]];

    NSString *docDir = [DataCenter getDocumentsDirectoryPath];

    NSString *fullPath = [docDir stringByAppendingPathComponent:filenamePath];

    NSURL *url = [NSURL fileURLWithPath:fullPath];
    UIDocumentInteractionController *c = [UIDocumentInteractionController interactionControllerWithURL:url];

    BOOL success = [c presentOpenInMenuFromBarButtonItem:buttonBack animated:YES];

我究竟做错了什么?谢谢

4

2 回答 2

18

对于那些坚持这一点的人:您根本不需要将自己设置为 UIDocumentInteractionController 的代表。

问题[UIDocumentInteractionController interactionControllerWithURL:url]是被自动发布。它认为它会被显示的操作表在内部保留,但显然不是。所以,是的,必须保留它,直到行动表被解雇。

于 2012-03-20T19:22:45.360 回答
0

尝试检查UIDocumentInteractionControllerDelegate方法documentInteractionController:willBeginSendingToApplication:documentInteractionController:didEndSendingToApplication:. 如果您的视图控制器是文档交互控制器的代表,那应该会提示您问题可能出在哪里。

此外,您应该验证您尝试在其他地方使用的文件(我假设是 PDF)实际上是您期望的文件。

于 2012-03-20T18:42:46.720 回答