Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trial
Paul Yorde
10,497 PointsimageView
HI,
I have a couple of issues with imageView. 1st: I have a background image set in imageView (non-programatically). The image shows up on the Main.storyboard (view), but not in the simulator view. (though that seems to work after a while). 2nd: I use this code, but now the image doesn't show up even on Main.storyboard.
UIImage *backgroundImage = [UIImage imageNamed:@"bgcalc"];
UIImageView *imageView = [[UIImageView alloc] initWithImage:backgroundImage];
[self.view insertSubview:imageView atIndex:0];
Any suggestions as to why those issues might be?
6 Answers
Stone Preston
42,016 PointsTry cleaning your project by selecting product -> clean. Changes in storyboard sometime don't get included in a build so you have to clean it first for them to get through. Your code should not affect what shows up in storyboard though. Does jt work when you run the app? Your code looks good so that should work
Paul Yorde
10,497 PointsThanks for the quick response. I did clean, but to no avail...
Paul Yorde
10,497 PointsAlso, what is jt?
Stone Preston
42,016 PointsDid you include your image in your project somewhere? Either in your project files or in the image catalog?
Paul Yorde
10,497 PointsYes, x1 and x2 are in Images.xcassets. The image does show up now when I add it from Main.storyboard, but still not programmatically.
Paul Yorde
10,497 PointsOk, scratch that. It's working now. Must have been internal glitches with my computer. That happens sometimes, and I should probably clean my system. Thanks for the tip (product > clean) ~
Paul Yorde
10,497 PointsPaul Yorde
10,497 PointsOh, and I just saw this in output: Could not load the "bgcalc.png" image referenced from a nib in the bundle with identifier.