UIDocumentInteractionController没有显示出来

Fab*_*bio 3 iphone objective-c ios

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控制器.

任何想法都将受到欢迎

Fab*_*bio 8

我回答我自己的问题:

我启动docInteractionController的表单是正确的,问题出在文件url中,它缺少正确的扩展名(在我的情况下是.pdf)和控制器UTI中的,它必须是扩展形式(com.adobe.pdf).

正确设置后,预览显示没有问题.