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

iOS

Error 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

UIImageView * imageView = [[*UIImageView* alloc] initWithImage:image]; 

You have to remove UIImage and add UIImageView in alloc.

That worked, but it seems to only be showing the top-left fourth of the picture now, any help?

Just 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

Thanks 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!