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
Noah Kirschbaum
Courses Plus Student 478 PointsError in programming Crystal Ball Image
Im working through the video titled "Programming a Background Image"
I am getting the error: No visible @interface for 'UIImage' declares the selector 'initWithImage'
My code for this section is as follows:
UIImage *image = [UIImage imageNamed:@"background@2x.png"];
UIImageView *imageView = [[UIImage alloc] initWithImage:image];
[self.view addSubview:imageView];
Any help would be appreciated, thanks!
4 Answers
Joshua Cleetus
785 PointsUIImageView * imageView = [[*UIImageView* alloc] initWithImage:image];
You have to remove UIImage and add UIImageView in alloc.
Noah Kirschbaum
Courses Plus Student 478 PointsThat worked, but it seems to only be showing the top-left fourth of the picture now, any help?
Joshua Cleetus
785 PointsJust use background.png no need to use background@2x.png the xcode will automatically use it if needed just keep that file in the folder
Noah Kirschbaum
Courses Plus Student 478 PointsThanks that did it for me, I figured background.png was sized for the iPhone 4, but using is seeming to work fine. Thanks for the help!