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


Deleted User

I Need Help!

Im having trouble "adding the UIImageView as a subview to the instance of UIView named 'catView'." (building an iPhone app:Making it pretty;Programming a background image)

i understand how to insert a subview but everytime i recheck my work it tells me i need to add a subview and not insert one. I'm confused because the video prior to the challenge shows me how to insert a subview and not add one.

here is my current code and im stuck on task 3.

UIView *catView = [[UIView alloc] init];

/* Write your code below this line */
UIImage *image = [UIImage imageNamed: @"lolcat.png"];
UIImageView *imageView = [[UIImageView alloc] initWithImage:image];
[self.view addSubview: imageView atIndex:0];

3 Answers

Deleted User


Why do you use the explicit declaration of catView and not self.view?

Amit Bijlani
Amit Bijlani
Treehouse Guest Teacher

There is no self.view because you are not using a UIViewController within the code challenge.