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
Kevin Blair
5,230 PointsProgramming a background image > Code Challange > Part 2 of 3
Okay, so I have completed step 1, but I still am pretty confused with how to pass step 2 of 3.
Create an instance of UIImageView called 'imageView' using the previously created UIImage.
Here's my code:
UIView *catView = [[UIView alloc] init];
/* Write your code below this line */
/* First Step */
UIImage *image = [UIImage imageNamed:@"lolcat.png"];
UIImageView *imageView = [[UIImageView alloc] initWithImage:image];
[catView addSubview:imageView];
/* Second Step (Wrong) */
UIImage *imageView = [UIImage imagedNamed:@"lolcat.png"];
UIImage *imageView = [[UIImageView alloc] initWithImage:imageView];
[imageView addSubview:imageView];
I know this is probably very wrong, but it's my best guess. Will someone be so kind to teach me?
Also, I am concerned I might need help with step 3 if I can't get past step 2!
Thanks!
Kevin
3 Answers
samiff
31,206 PointsHey Kevin, this should help you out:
http://teamtreehouse.com/forum/programming-a-background-stuck-on-code-challenge
Kevin Blair
5,230 Points@Sam Thanks Sam! However, I've already read that link and if I'm not mistaken, I think it only covers part 1 of 3 on that problem. If it covers part 2 please show me exactly where and call me crazy haha!
And how did you earn a Treehouse Scholarship Badge?! Cool!
Also, I tried using the Markdown Cheatsheet to put my code into a box, but for some reason it didn't work? User error I'm sure. Anyone's advice is appreciated.
samiff
31,206 PointsUIImageView *imageView = [[UIImageView alloc] initWithImage:image];
You can see this thread for formatting code blocks with my preferred method, backticks.
The scholarship badge was from receiving one of Treehouse's awards. I'm very grateful and hope to showoff what I've learned very soon!