objective c - UIImage failed to be loaded for IOS 7.x SPECIFIC -
i trying load image using method:
[uiimage imagenamed:imagename]
[uiimage imagewithcontentsoffile:imagepath]
in ios 8.x, images loaded. in ios 7.x simulators, above methods return nil. situation happened in both simulators , devices.
nsbundle *mybundle = [nsbundle findmybundle]; [mybundle load]; nsstring *imagepath = [nsstring stringwithformat:@"%@/%@", [mybundle bundlepath], imagename]; uiimage *targetimage = [uiimage imagewithcontentsoffile:imagepath]; nslog(@"frameworkbundle: %@", mybundle); // bundle exist ios 7.x nslog(@"image: %@", targetimage); // targetimage = nil ios 7.x; while return image ios 8.x
is there method need notice loading uiimage ios 7.x devices / simulators.?
edit:
here worked out me:
// have specify imagetype @"png" // if 1 compose path without filetype ending, not load image properly. nsstring *imagepath = [mybundle pathforresource:imagename oftype:@"png"]; uiimage *myimage = [uiimage imagewithcontentsoffile:imagepath];
i think there change when ios 8 launched in how , bundles exist, search on stackoverflow , question (and answer can you), have use different loading method locating bundle or resource
ps:should have been comment in answer dont have enought reputation @ moment :)
Comments
Post a Comment