UIDocumentInteractionController当用户从中选择一个文件时,我试图从导航控制器中呈现一个tableView.
在interactionControllerWithURL返回NO和委托方法documentInteractionControllerViewControllerForPreview,不会被调用的documentInteraction控制器不会出现.
当用户选择表中的项时,将执行以下代码:
NSURL *fileURL;
fileURL = (NSURL *)[[DataMng sharedMng] getFileInFolder:self.navigationItem.title atRow:indexPath.row type:type];
if (self.docInteractionController == nil){
self.docInteractionController = [UIDocumentInteractionController interactionControllerWithURL:fileURL];
if (!self.docInteractionController) {
NSLog(@"Selected a file with estension not supported for visualization");
return;
}
self.docInteractionController.delegate = self;
}else{
self.docInteractionController.URL = fileURL;
}
if(! [self.docInteractionController presentPreviewAnimated:YES]){
NSLog(@"ERROR in presenting preview");
}
Run Code Online (Sandbox Code Playgroud)
委托控制器(self)符合UIDocumentInteractionControllerDelegate协议,是控制器内的导航Tabbar控制器.
任何想法都将受到欢迎