While working for this semester’s CSCW lab project, I encountered a strange situation: no matter what I did, the UIImageView didn’t load the image. After some digging on the Internet about this, I found out that first thing to look for is whether you’re sending the setImage message to the UIImageView instance you expect.
Being newbie in XCode and Apple’s technologies in general, I forgot to use NSLog. So my advice is to check and check often with NSLog for a nil pointer in the same place you’re trying to set the image. Obj-C loves to make freshman crazy by sending messages to nil pointers without any warning or other problem. So check if the pointer is nil, double check the IBOutlet connection to the UIImageView in IB.
Don’t forget also that if you change the name of any IBOutlet or IBAction you have to redo the connections in Interface Builder!!!
If the pointer isn’t nil, please make sure you didn’t reallocate it someplace in your code. It’s easy to get confused, especially when doing all stuff programmatically (because sometimes the application is faster) and alloc another instance of UIImageView which would then be happy to accept the image message while the view which is actually visible remains unchanged. You might try sending a different message to the view, e.g. resetting the frame, to be on the safe side.
When you’re convinced the message is going to the right view, check the line that sends the message; it should look something like this:
[[imageView setImage:[UIImage imageNamed:@"Picture.jpg"]];