Ios UIDocumentInteractionController显示文件名和文件类型,而不是文件内容

Ios UIDocumentInteractionController显示文件名和文件类型,而不是文件内容,ios,objective-c,Ios,Objective C,我有NSData,它以.pdf文件扩展名保存在文档目录中的一个文件夹中&当我尝试使用UIDocumentInteractionController打开它时,它只显示文件名和类型,而不显示内容。我检查了模拟器的文档目录文件夹&那里有一个.pdf文件 //Saving NSData + (NSString *)createTempDocumentDirectory:(NSString *)dirName andStoreData:(NSData *)

我有
NSData
,它以.pdf文件扩展名保存在文档目录中的一个文件夹中&当我尝试使用
UIDocumentInteractionController
打开它时,它只显示文件名和类型,而不显示内容。我检查了模拟器的文档目录文件夹&那里有一个.pdf文件

//Saving NSData
+ (NSString *)createTempDocumentDirectory:(NSString *)dirName
                         andStoreData:(NSData *)data
                         withFileName:(NSString *)name
                     andFileExtension:(NSString *)extension
{
    NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
    NSString *documentsDirectory = [paths objectAtIndex:0]; // Fetch path for document directory
    NSMutableString *dirPath = (NSMutableString *)[documentsDirectory stringByAppendingPathComponent:dirName];
    NSString *fileName = [NSString stringWithFormat:@"%@.%@", name, extension];
    NSString *path = [dirPath stringByAppendingPathComponent:fileName];

    return path;
}                         //Presenting contents of view

- (void)loadDocumentPreview:(NSURL *)fileURL
{    
    if (fileURL)
    {
        self.documentInteractionController = [UIDocumentInteractionController interactionControllerWithURL:[self fileURLDocumentPath:documentPath]];
        self.documentInteractionController.name = @"";
        [self.documentInteractionController setDelegate:self];
        [self.documentInteractionController presentPreviewAnimated:YES];
    }
}

显示您尝试过的代码片段…您能告诉我们如何调用此方法吗:loadDocumentPreview:@TonyTran问题已解决。我使用了错误的方法来创建fileURL,现在我使用了“fileURLWithPath”&它工作正常。感谢您展示了您尝试过的代码片段……您能否向我们展示如何调用此方法:loadDocumentPreview:@TonyTran问题已解决。我使用了错误的方法来创建fileURL,现在我使用了“fileURLWithPath”&它工作正常。谢谢