The ModMyTM Family of Sites:
ModMyMotoModMyiModMyGphone




 
 
Register or Connect with Facebook

Discuss AppStore Apps | Browse / Search Cydia | MMi Cydia Stats




  Apple Forums & iPhone Forums, Mods, Hacks, News, Themes, Downloads, and more! | ModMyi.com > 3rd Party Apps For iPhone | iPod Touch > iPhone / iPod Touch SDK | Development Discussion
Reply
 
LinkBack Thread Tools Display Modes
  #1  
Old 03-14-2008, 11:53 AM
Livin the iPhone Life
 
Join Date: Dec 2007
Posts: 1,403
Thanks: 15
Thanked 175 Times in 167 Posts
UIImage:imageNamed - where does it look for images?

hi,
I'm pretty new to iPhone development (or cocoa development for that matter) and I recently tried setting up a toolbar. It works, the only problem is it doesn't show the images for every toolbarItem. I tested a little and found out that my UIImage Object returned nil.
Now my question: Where does UIImage:imageNamed look for images?
I put an image called "FeaturedOff.png" into the main project directory (so the directory where the main.m lies) and then I tried

[UIImage imageNamed:@"FeaturedOff.png"]

but it just returns nil. same for other images. why?
finder shows the images just fine so I guess it has nothing to do with my images being broken or something.

thanks :-)
Digg StumbleUpon Delicious Reddit Newsvine Google Yahoo Thanks Reply With Quote
  #2  
Old 03-14-2008, 02:35 PM
NetMage's Avatar
Developer
 
Join Date: Aug 2007
Device + Firmware: iPhone 2.2.0
Operating System: Windows XP / OS X
Location: Virginia
Posts: 1,231
Thanks: 45
Thanked 202 Times in 162 Posts

The code you listed is executed when your program is running.

Did you copy your png into the Application bundle that you put on the iPhone when running your test?
Digg StumbleUpon Delicious Reddit Newsvine Google Yahoo Thanks Reply With Quote
The Following User Says Thank You to NetMage For This Useful Post:
BlackWolf (03-15-2008)
  #3  
Old 03-14-2008, 08:21 PM
What's Jailbreak?
 
Join Date: Feb 2008
Device + Firmware: iPod touch 1.1.4
Operating System: Leopard, Vista, XP and Ubuntu ^^
Location: Basel, Switzerland, Europe
Posts: 8
Thanks: 0
Thanked 1 Time in 1 Post

Hey.

Try this:
On the left side in XCode, where all your class files etc. are listed, create a new group (=folder) for example "images". Then rightclick on the new group and select "From existing File" or something like that and add your *.png file. Then it should work:

[UIImage imageNamed:@"NameOfYourPicture.png"]

I am not sure if this is the best solution, but I saw it in one of the sample codes on the iphone dev center.
Digg StumbleUpon Delicious Reddit Newsvine Google Yahoo Thanks Reply With Quote
The Following User Says Thank You to DrummerB For This Useful Post:
BlackWolf (03-15-2008)
  #4  
Old 03-14-2008, 09:50 PM
iPhone? More like MyPhone
 
Join Date: Aug 2007
Posts: 104
Thanks: 19
Thanked 13 Times in 8 Posts
Send a message via AIM to swell

I think what your problem is that your .png is in the directory in Finder but, it's not added to your project. What you need to do is single click on any item in your project, then go up to the ACTION pull down tab and select ADD, then EXISTING FILES. Once you have done this select your .png's. This will add your .png's to the project, allowing your code to discover them. I believe this is what DrummerB was getting at, I just wanted to help make it more clear.

Hope this helps,

Swell
Digg StumbleUpon Delicious Reddit Newsvine Google Yahoo Thanks Reply With Quote
The Following User Says Thank You to swell For This Useful Post:
BlackWolf (03-15-2008)
  #5  
Old 03-15-2008, 05:24 AM
Livin the iPhone Life
 
Join Date: Dec 2007
Posts: 1,403
Thanks: 15
Thanked 175 Times in 167 Posts

yeah, thank you very much guys, it works perfectly fine :-)
Digg StumbleUpon Delicious Reddit Newsvine Google Yahoo Thanks Reply With Quote
Reply

  Apple Forums & iPhone Forums, Mods, Hacks, News, Themes, Downloads, and more! | ModMyi.com > 3rd Party Apps For iPhone | iPod Touch > iPhone / iPod Touch SDK | Development Discussion

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



Go to Top
ModMyI

All times are GMT -6. The time now is 10:01 PM. Powered by vBulletin® Version 3.8.4
If you need Dedicated Server Hosting, you should check out SingleHop. | Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.3.0 Copyright © 2007-09 by ModMy, LLC. All rights reserved.

iPhone News / iPhone Forums / Apple News / Apple Forums / RSS / Contact Us / / Privacy Statement / Top