UIDocumentsInteractionController显示iBooks,但不打开它
我的UIDocumentsInteractionController正在工作,只要提交一个button,说“iBooks”,但当我点击该button,它只是解散,它不会带我到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];
我究竟做错了什么? 谢谢
对于那些坚持这一点:你不需要自己设置为UIDocumentInteractionController的委托。
问题是[UIDocumentInteractionController interactionControllerWithURL:url]
正在被autoreleased。 它认为这将被保留在内部的行动表被显示,但显然不是。 所以,一定要保留,直到行动表被解散。
尝试检查UIDocumentInteractionControllerDelegate
方法documentInteractionController:willBeginSendingToApplication:
和documentInteractionController:didEndSendingToApplication:
如果您的视图控制器是文档交互控制器的委托,那么您应该知道问题出在哪里。
另外,你应该validation你正在尝试使用的文件(我假设的一个PDF)实际上是你所期望的。