Loading an Image from documents directory

后端 未结 6 1816
温柔的废话
温柔的废话 2020-12-03 13:51

I cant get my Image(.png) to display.

I check that it exists at the path I use, and it does. But no image appears.

Here is what I\'ve been trying:

         


        
6条回答
  •  没有蜡笔的小新
    2020-12-03 14:18

    Try to use

    NSData *imgData = [NSData dataWithContentsOfFile:imgPath];
    UIImage *thumbNail = [[UIImage alloc] initWithData:imgData];
    

    or

    NSData *imgData = [[NSData alloc] initWithContentsOfURL:[NSURL fileURLWithPath:imgPath]];
    UIImage *thumbNail = [[UIImage alloc] initWithData:imgData];
    

提交回复
热议问题