objective c - UIImage failed to be loaded for IOS 7.x SPECIFIC -


i trying load image using method:

  1. [uiimage imagenamed:imagename]
  2. [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

ios 8: bundle path changes

ps:should have been comment in answer dont have enought reputation @ moment :)


Comments

Popular posts from this blog

android - MPAndroidChart - How to add Annotations or images to the chart -

javascript - Add class to another page attribute using URL id - Jquery -

firefox - Where is 'webgl.osmesalib' parameter? -