Show image from documents folder
I retrieve an image I have saved at the documents directory like this:
//set background image
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0]; // Get documents folder
NSString *imagePath = [documentsDirectory stringByAppendingPathComponent:@"/myFolder/back.png"];
开发者_Python百科 backgroundImage.image =[UIImage imageWithContentsOfFile:imagePath];
But it is not shown :(
What am I doing wrong?
PD:Yes, it has been saved with the same path and filename (no upper/lower case differences) and yes, I tried opening the image at that path and it works.
Thanks in advance!
It was being done in the wrong place. I was doing it at init instead of viewDidLoad.
精彩评论