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![](https://ecs-static.teamtreehouse.com/assets/views/marketing/shared/community-banner-white-47072046c51352fe6a69f5e691ff5700b28bb11d45197d7bdf066d9ea3f72d0c.webp)
![Kal K](https://uploads.teamtreehouse.com/production/profile-photos/370672/micro_ichgo2.png)
Kal K
13,332 PointsSetting Background Images for Various Screen Sizes Error
I have tried all of the things recommended by Ben in the video after his app did not work either. i have found that app at the size of 3.5 inches works but at 4 inches i just have a white background. Can someone please help me? Perhaps you can help Ben Jakuben? Here is the code i had to display the bigger picture
- (void)viewDidLoad {
[super viewDidLoad];
if ([UIScreen mainScreen].bounds.size.height == 568) {
self.backgroundImageView.image = [UIImage imageNamed:@"loginBackground-568h"];
}
}
8 Answers
![Thomas McCracken](https://uploads.teamtreehouse.com/production/profile-photos/1091072/micro_IMG_0004.jpg)
Thomas McCracken
13,591 PointsOk, I couldn't get the 4" image to come in so I just stretched the 3.5" image to fill the screen as a quick fix:
if ([UIScreen mainScreen].bounds.size.height == 568) { self.backgroundImageView.frame = self.view.frame;
self.backgroundImageView.image = [UIImage imageNamed:@"loginBackground"];
}
Hopefully this is just a work-around until someone...(ahem, Ben)...solves this mystery.
![Charlie O'Shea](https://secure.gravatar.com/avatar/27a4390479c6945bbd017c162025ed43?s=96&d=https%3A%2F%2Fecs-static.teamtreehouse.com%2Fassets%2Fcontent%2Fdefault_avatar-445fbbabfc8dc9188fb5967fe43322ee0c3e0dd1e10f378bf8343784af5a13eb.webp&r=pg)
Charlie O'Shea
18,737 PointsNo luck for me either. Followed all fixes in video to no avail. Also tried reuploading the 568 image without the hyphen incase that was interfering but didn't work. Going with Thomas McCrackens quick fix for now but would be great to learn how to do this properly Ben. I'm in XCode 6 by the way.
Oh and another thing which I couldn't do in the video was making the Storyboard view controllers toggle between 3.5 and 4 inches as the button seems to have vanished in Xcode 6. I could use the assistant editor preview to see other screen size, but can't work out how I can stretch the image to 4inch size as per the video.
![Daniel Monday](https://secure.gravatar.com/avatar/b51e8c682bd794d72fac1c6f98b4ce86?s=96&d=https%3A%2F%2Fecs-static.teamtreehouse.com%2Fassets%2Fcontent%2Fdefault_avatar-445fbbabfc8dc9188fb5967fe43322ee0c3e0dd1e10f378bf8343784af5a13eb.webp&r=pg)
Daniel Monday
140 PointsI'm also having the same issue, did you find a way around this?
Thanks
![David Kusek](https://secure.gravatar.com/avatar/7aadd61f44671b579170960c5238bb9d?s=96&d=https%3A%2F%2Fecs-static.teamtreehouse.com%2Fassets%2Fcontent%2Fdefault_avatar-445fbbabfc8dc9188fb5967fe43322ee0c3e0dd1e10f378bf8343784af5a13eb.webp&r=pg)
David Kusek
2,880 PointsAlso stuck here
![Christopher Santos](https://secure.gravatar.com/avatar/28c2340b1a833bb5b487dc2c00d4b164?s=96&d=https%3A%2F%2Fecs-static.teamtreehouse.com%2Fassets%2Fcontent%2Fdefault_avatar-445fbbabfc8dc9188fb5967fe43322ee0c3e0dd1e10f378bf8343784af5a13eb.webp&r=pg)
Christopher Santos
Courses Plus Student 10,697 PointsI was able to display the background by using @"loginBackground" for the filename instead of @"loginBackground-568h" But that is the file name of the lowest res image. Maybe xcode doesn't like the special characters in the file names of the higher res images.
![Thomas McCracken](https://uploads.teamtreehouse.com/production/profile-photos/1091072/micro_IMG_0004.jpg)
Thomas McCracken
13,591 PointsI'm having the same issue too. The "loginBackground" image works fine just like Christopher Santos said but not "loginBackground-568h". Really wish I could figure out a solution...I'm going to try changing the name to exclude the dash and see what happens.
![Gareth Holton](https://secure.gravatar.com/avatar/e6f1208bddb4551c402ef95aa2eb2ccd?s=96&d=https%3A%2F%2Fecs-static.teamtreehouse.com%2Fassets%2Fcontent%2Fdefault_avatar-445fbbabfc8dc9188fb5967fe43322ee0c3e0dd1e10f378bf8343784af5a13eb.webp&r=pg)
Gareth Holton
258 Pointsthe way i found to to solve the problem was to simply resize the image which fortunately doesn't seem to blur or pixelate the image simply add
loginBackground.frame = CGRectMake(0, 0, 320,568);
you could also expand on this and create integers in the if statements that then equal the width and height of the current device and pass them through the parameters of the CGrect hope this helps !
![Pablo Alfaro](https://secure.gravatar.com/avatar/0723707102ec19c4d6cde2dc299ad998?s=96&d=https%3A%2F%2Fecs-static.teamtreehouse.com%2Fassets%2Fcontent%2Fdefault_avatar-445fbbabfc8dc9188fb5967fe43322ee0c3e0dd1e10f378bf8343784af5a13eb.webp&r=pg)
Pablo Alfaro
Courses Plus Student 6,923 PointsA workaround that worked for me was to add constraints to the UIImageView. I pinned all four sides at 0 and have tested it on iPhone 4 - iPhone 6s plus and it seems to work fine without the images getting pixelated or distorted.