mercredi 13 juillet 2016

UIDocumentInteractionController showing file name and file type , not file contents

I have NSData , which i saved in a folder inside document directory with .pdf file extension & when I try to open it using UIDocumentInteractionController it is showing me only file name & type, not the content. I checked in document directory folder for simulator & a .pdf file exists there.

//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]; 
    }
     }

Aucun commentaire:

Enregistrer un commentaire