开发者

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜