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
Gareth Holton
258 PointsHow would you be able to detect a screen size and input it progromatically depending on the device?
As Apples product line continues to expand. How would you about inputting the new image sizes programatically depending on the device and screen size? At the moment we are using this code:
''' UIImage *newImage = [self resizeImage:self.image toWidth:320.0f andHeight:480.0f];
''' which is ok for one particular device but know good in the 'real world' but how would you do it so the code detects the devices and inputs the parameters for you ?
thanks in advance
Gareth
1 Answer
Nick Sint
4,208 PointsIn the view controller file you have two options:
Option 1: [[UIScreen mainScreen] bounds].size.height [[UIScreen mainScreen] bounds].size.width
Option 2: self.view.frame.size.height self.view.frame.size.width
Or you could play around with Autolayout until it comes out right to how you want.