The following code returns an image object from path
and works previous to iOS 11:
NSString *path = [anotherPath stringByAppendingPathComponent:file];
UIImage *image = [UIImage imageNamed:path];
However in iOS 11, image
returns null
. Is this an iOS 11 bug?
+[UIImage imageNamed:]
is documented as taking a filename, not a path. If you want to load an image from a path, use+[UIImage imageWithContentsOfFile:]
.If your path here is referring to something in a nested folder in your bundle, you can ask
NSBundle
for the path for the resource and then pass that to+[UIImage imageWithContentsOfFile:]
. This would look like