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

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

Amit Bijlani
Treehouse Guest TeacherAlmost right, except that your last line should be:
[catView addSubview:imageView];
For an explanation please see the following posts:

thanks.

Steve Schofield
Courses Plus Student 7,465 PointsWhy do you use the explicit declaration of catView and not self.view?

Amit Bijlani
Treehouse Guest TeacherThere is no self.view
because you are not using a UIViewController
within the code challenge.