Discussion Forums  >  Plugins, Customizing, Source Code

Replies: 10    Views: 61

basement
Aspiring developer
Profile
Posts: 488
Reg: Apr 07, 2011
Ontario
4,880
04/02/13 05:19 AM (12 years ago)

iPhone4/5?

I am working on an app that will have images showing golf course holes. I want the images to fill the iPhone screens, but how do I differentiate between iPhone4 and iPhone5 so the image work with both screens? I don't really want them to be squished up to fit onto a 4, or stretched to fit to a 5. I'd rather provide both size images and somehow have the phone use whichever's appropriate. thanks!
 
Nick Langley
Apple Fan
Profile
Posts: 288
Reg: May 08, 2012
Birmingham, Uni...
11,580
like
04/02/13 05:30 AM (12 years ago)
iPhone 4 = 640 x 960, iPhone 5 = 640 x 1136. If you want to achieve this without stretching an option you may want to have a look at is doing all of your artwork to fit the iPhone 5, make your artwork so that the 176 pixels on the bottom of you iPhone 5 artwork don't look odd when they are missing off the bottom of the iPhone 4 screen. (I.e. not having crucial text or logos in that area, otherwise they will be missing off the bottom of the iPhone 4 screen). Photoshop: "Save for Web and Devices" Option is the one to choose, then set the correct resolution. :) not got Photoshop? Check out http://www.splashup.com -Nick
 
basement
Aspiring developer
Profile
Posts: 488
Reg: Apr 07, 2011
Ontario
4,880
like
04/02/13 05:31 AM (12 years ago)
yep, thanks. I thought of that, but would have preferred not to do it that way. I guess it's the easiest!
 
Nick Langley
Apple Fan
Profile
Posts: 288
Reg: May 08, 2012
Birmingham, Uni...
11,580
like
04/02/13 05:36 AM (12 years ago)
If you were to do it purely in Xcode then obviously you could just have two different sets of artwork... someone may have a work around to code in but it will be laborious. If apple were to have made the iPhone 5 like 816 x 1136 that would have been nice of them.
 
MGoBlue
Apple Fan
Profile
Posts: 980
Reg: Jun 07, 2011
Gold River, CA
10,600
like
04/02/13 06:09 AM (12 years ago)
Create two versions of your images, one sized for iPhone 4 and one for iPhone 5. Name the iPhone 5 version with an extension of "[email protected]" and iOS will pull the correct image automatically. For instance: 320x480 = "background.jpg" 640x960 - "[email protected]" 640x1136 = "[email protected]"
 
chris1
Code is Art
Profile
Posts: 3862
Reg: Aug 10, 2012
Austin, TX
50,120
like
04/02/13 06:10 AM (12 years ago)
It's not laborious in code actually. Just get the size of the screen and display the proper image using either an if/else statement or a switch/case
 
chris1
Code is Art
Profile
Posts: 3862
Reg: Aug 10, 2012
Austin, TX
50,120
like
04/02/13 06:10 AM (12 years ago)
Or what MGOBlue said :)
 
Nick Langley
Apple Fan
Profile
Posts: 288
Reg: May 08, 2012
Birmingham, Uni...
11,580
like
04/02/13 07:10 AM (12 years ago)
This doesn't work for me... I've just uploaded a file called "home.png" in BT CP and I've made another called "[email protected]" and popped then both into the xcode project... nothing happens.
 
chris1
Code is Art
Profile
Posts: 3862
Reg: Aug 10, 2012
Austin, TX
50,120
like
04/02/13 07:42 AM (12 years ago)
You can get the device's height and width like this: int Width = appDelegate.rootApp.rootDevice.deviceWidth; int Height = appDelegate.rootApp.rootDevice.deviceHeight; (assuming you have initialized the appDelegate in your method before declaring the above variables.) For distinguishing between iPhone 4 & 5, all you'll need is the height. Are you trying to add the picture to a plugin already in use, or a new screen/plugin you're working on?
 
Nick Langley
Apple Fan
Profile
Posts: 288
Reg: May 08, 2012
Birmingham, Uni...
11,580
like
04/02/13 08:01 AM (12 years ago)
A new one ... :)
 
chris1
Code is Art
Profile
Posts: 3862
Reg: Aug 10, 2012
Austin, TX
50,120
like
04/02/13 08:16 AM (12 years ago)
Good. Then you should be able to do something like this: //replace "BT_appDelegate" with the name of your appDelegate file BT_appDelegate *appDelegate = (BT_appDelegate *)[[UIApplication sharedApplication] delegate]; //get device height int Height = appDelegate.rootApp.rootDevice.deviceHeight; //define image name in a string variable NSString *theImage = @"home.png"; if (Height > 480) { //we are an iPhone5 theImage = @"[email protected]"; } //set the image someImageView.image = [UIImage imageNamed:theImage];
 

Login + Screen Name Required to Post

pointerLogin to participate so you can start earning points. Once you're logged in (and have a screen name entered in your profile), you can subscribe to topics, follow users, and start learning how to make apps like the pros.