Sh*t my brain says and forgets about

Loading a UIImage from a bundle

I’ve been scratching my freaking head for an hour trying to figure out how to load an image from my application’s bundle.  Doing this in Interface Builder is easy as pie, but not so straightforward.

[UIImage imageWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@”thefilename” ofType:@”jpg”]];

Easy, isn’t it?

Previous

Google App Engine & Java

Next

Thoughts on the iPhone 3GS

5 Comments

  1. Thanks. You’re the first hit from “UIImage load bundle” and told me exactly what I needed.

    Tom

  2. admin

    Glad I could help!

  3. Cheese[OnToast]

    Great stuff, spot on here too!

  4. I have found that this

    UIImage* I = [[UIImage imageNamed:@”image.png”] retain];

    Also really works.

    Tom

  5. objective-c

    Thanks 😉

Leave a Reply

Your email address will not be published. Required fields are marked *

Powered by WordPress & Theme by Anders Norén