Iphone : How to Display Document Directory images in Image View?

后端 未结 7 2346
星月不相逢
星月不相逢 2020-12-01 17:07

In a App images stored in Document Directory Folder,

I wanted Particular image display in Image view,

How that image Display in Image View from the Document

7条回答
  •  猫巷女王i
    2020-12-01 17:25

    Adding to these answers I find its good practice to check if the file exists like so...

    NSString *directory = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0];
    NSString *file = [directory stringByAppendingPathComponent@"my_image.jpg"];
    if ([[NSFileManager defaultManager] fileExistsAtPath:file]) {
        self.myimageview = [UIImage imageWithData:[NSData dataWithContentsOfFile: file]];
    
    }
    

提交回复
热议问题