tags:

views:

204

answers:

4

I dragged an image from the Media Library in my Interface Builder and can see the image in my xib. However, when I open up the iPhone Simulator the image isn't there. Do I need to put code into the program's .m or .h to be able to show the image I have on IB?

+1  A: 

You need to add the Image to the "Resources" Folder in your Application Directory, so that the Image can be copied to your target "Copy Bundle Resources", this folder contains all the resources your application is using. Otherwise when the iPhone Simulator runs it will not find the image

In order to add an Image to the Resources ctrl+click the folder and select add..-> existing files, then select your image and click Add.

Hope that is clear.

-Oscar

OscarMk
it is in both my Resources folder in XCode and my application folder/bundle on my Desktop
HollerTrain
Can you see anything else in the view?. Try dragging an UILabel to check, maybe the view controller is not tied to that view?.
OscarMk
Yeah I believe I have everything where it should. (http://screencast.com/t/MjIxZmNlM). Do I need to right click the image and connect it to the File or View?
HollerTrain
A: 

Well I never used IB that much for that to understand what you're doing.

But, the steps that I used to take is:

  1. Make sure the image resources path is correct, and it's local to the project, not referenced from an unknown path.

  2. Make sure it's shown in UIImageView inspector in the IB.

  3. Select the image name inside the inspector.

  4. Make sure the image is displayed in the UIImageView placeholder.

If things go wrong with IB, I'd rather write code, initialize UIImageView instance at the right position. It's less headache for debugging.

Jesse Armand
A: 

If by 'opening the Simulator' you mean that you select Simulate Interface from Interface Builder's File menu, then yes, that will not work.

To run your application in the simulator you will have to hit the Build and Run button in Xcode.

St3fan
A: 

Is the "hidden" box checked in IB? Or maybe in your code or in IB you set alpha to zero? Just to make sure, connect the image in IB to your code in the .h file, and in your .m type this in your viewDidLoad: function:

image.alpha = 1;
image.hidden = NO;

Try this and tell me if it works!

Flafla2
ah my issue is i dont have code in the .m or .h files. so i guess i need to figure out how i can set that up
HollerTrain