Sunday 15 July 2012

ios - Can't load images from bundle into storyboard -



ios - Can't load images from bundle into storyboard -

i've been working on library used across multiple applications. library includes resources storyboard , many images. made library .framework using ios framework tutorial found on github.

when first working on library, in form of app. when got of coding done, made framework. however, problem began.

i able nowadays storyboard (engine.bundle/platform.storyboardc), , first screen shows has background image loads. however, 1 time of other screens in storyboard, images on screens don't load. what's weird first screen image loads through storyboard without having set in code. other images storyboard don't load, yet contained in same bundle first image.

one of next screen contains credit card images, not load. , on screen after that, more credit card images don't load. however, 1 time set images through .m file, load bundle , show on screen. yet when utilize same code on every other screen doesn't show respective images, code doesn't work. here's code i'm using load respective images:

nsbundle *bundle = [nsbundle bundlewithurl:[[nsbundle mainbundle] urlforresource:@"engine" withextension:@"bundle"]]; nsstring *filepath = [bundle pathforresource:@"front" oftype: @"png"]; backgroundimageview.image = [uiimage imagewithcontentsoffile:filepath];

whenever screens don't have images loaded presented, next logged console:

could not load "visa.png" image referenced nib in bundle identifier "com.example.app" not load "mastercard.png" image referenced nib in bundle identifier "com.example.app" ... , on , forth each image.

and shows on sec credit card image screen... screen images load. yet, doesn't show on first screen presented image loads.

my bundle structured so:

engine.bundle/ platform.storyboardc front.png visa.png amex.png ... on , forth.

my question why don't images load? , why load? front.png loads, , on 1 screen credit card images show. yet when utilize same code load images on other screens, code doesn't work.

sorry if post long... it's lot of detail. i've been trying figure out. if didn't explain right, please allow me know. thanks.

okay, sounds need set bundle identifier engine bundle.

use "com.iamsoawesome.engine"

then, instead of using:

nsbundle *bundle = [nsbundle bundlewithurl:[[nsbundle mainbundle] urlforresource:@"engine" withextension:@"bundle"]];

you can use:

nsbundle *bundle = [nsbundle bundlewithidentifier: @"com.iamsoawesome.engine"];

ios objective-c iphone xcode bundle

No comments:

Post a Comment