Managing iPhone 5 and iPhone 6 image sizes - iphone

I am new to programming and Xcode and struggling with setting image size for iPhone 5 and iPhone 6. Apparently both iPhone 5 and 6 use the #2x image while the 6+ use the #3x image. So i can design the 6+ perfectly, however since both iPhone 5 and 6 use the same image and they have different screen size/ resolution, mu screen design is impacted.
If I design the images as per iPhone 6 size, the images appear too big on iPhone 5 and if I design them as iPhone 5 then they appear to be too small on iPhone 6. This should be simple, what am I missing?
Please help!

Instead of directly using the images you should create an entry for them in the Images.xcassets. Select it in your Project Navigator.
Then drag and drop the #3x or #2x version of your image from the images folder into the list of images in the Images.xcassets window. This will automatically generate a new entry. Then drag the other (#2x or #3x) image into its proper position. It will look like this in the end.
Once that is done you can use it in the UIImageView, or Image for a button or whatever in your Storyboard as just the name without the #2x or #3x.
Now to finally answer your question. You should handle all of the image sizes with constraints in the storyboard. So for instance if you want the same margins on either side of your image you will create constraints between the size of the UIImageView that contains your image and the edge of the Superview. This way the image will be resized for each new screen.
Edited to add Be careful of the Constrain to margins check box as you want to be consistent with using it or not otherwise you will get behavior you didn't plan for. I always uncheck it and have my constraints go to the superview edge, but it doesn't matter as long as you are consistent across your App you won't get confused.

Related

Why does iPhone app resize for iPad but not iPhone 5

Why do original iPhone applications (normal screen size like iPhone 4/4s) in Xcode resize perfectly for iPad automatically and not for the slightly larger iPhone 5 screen size?
To fit a iPhone 4 view into the iPad each point is scaled equally into two directions. The aspect ratio of a iPhone4-point doesn't change on the iPad screen.
To fit a iPhone 4 view onto the iPhone 5 screen, each point has to be scaled in vertical direction only. This will distort each point and the view, similar to the distortions you get when you watch a movie in the wrong aspect ratio. A circle on the iPhone 4 screen won't be a circle on the iPhone 5. So you can't physically resize the pixels like it's done on the iPad.
In iOS-Development Autoresizing Masks come to the rescue. But there is no way to figure out if your app looks good if the auto resizing scales the view to iPhone 5 size. You have to test each app on a iPhone 5 sized screen. Apple didn't want to do this, so they put an opt-in in place, which you actively had to enable. They choose to use the iPhone5 launch image for that.
If your app looks good when it's vertically scaled simply provide the appropriate launch image.
If you used best practices to develop your iPhone 4 app that's basically all that is needed.
iPhone 5 support needs to be explicitly added by supplying a "Default-568h" start image.

iPhone 5 app compatibility, Is it mandatory to change all the images?

I want to make my App compatible for iPhone 5, i got the point about auto resizing just need to confir, Do i need to add all the images re-sized for iPhone 5 OR can work with re-sizeing only Splash and Background image ?
You will be required to resize the launch images. You need a launch image for the older iPhone screen sizes in normal and retina resolutions as well as an iPhone 5 screen size retina image.
It will be a good idea to rework your app and have background images that can take advantage of the larger iPhone 5 screen size, but will be able to be cropped and still work on the older iPhone screens.
Using either auto layout or setting the resize and pinning struts properly, your other controls and images should be able to be used as they are to adapt your app to look good on the iPhone 5 screen.
You only need to resize the splash screen.

Handling the larger device size of iPhone 5 [duplicate]

This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
How to deal with iPhone 5 screen size?
Watched the iPhone 5 keynote and yes the device height and a resolution of 640 X 1136. So I saw they showed how existing apps which work on that. But I believe if we use native components like tab bar, navigation bar etc. will work fine. But how about custom tab bars, navigation bars and controls which resides relative to the device orientation. So these are my questions.
1) How to handle custom layouts which has custom tab bars, navigation bars, relative contents etc.
2) Welcome screen. We will need 2 sizes right now. So in iPhone 5 do we need another 2 more for normal and retina?
3) If you carefully watched the keynote seems iPhone 5 will cut some portion of view from left and right so there is no any additional change in the app development. Has anybody noticed that?
1) This depends on how you laid them out, you might need to adjust how you set the frame, change autoresizing masks etc, or if iOS 6 only is an option you could move to auto layout. Without knowing your code I cant give much more detail
2) There is no non-retina iPhone 5 so you only need 1 more Default.png size, named Default-568h#2x.png (btw adding this new sized default image is the trigger for iOS to show your app without letterboxing, so for some apps this is the only change which will need to be made)
3) This is the letterboxing I mentioned, it is what all current apps will do on the iPhone 5 until they are updated with a new default.png
My understanding is that all existing apps will work on iPhone 5 and you will just have the black borders. However you will now have the capability to tailor apps to the bigger screen size. I imagine that there will now be a new sized .xib or storyboard that will match the size of the iPhone 5. You will be able to put an if statement in the app delegate to choose which .xib/storyboard to load based on the screen size. unfortunately now I think we will have to create multiple .xib/storyboard files, similar to how universal apps are made at the moment. The file loaded is selected based on the device.
Hope this helps

How to resize Cutom Buttons and Labels according to iphone 4?

I have an application containing number of images, custom buttons having images and number of labels.
My problem is to resize those buttons,images and labels according to iphone 4 as wel as iphone 3.
i know that images named #2x are used for high resolution, but I cant find any way to enlarge my custom buttons and labels and also those images which didn't define in code.
how do I get their exact position??
Although screen resolution of iPhone is 640x960, screen dimensions for UIKit are still 320x480 so normally you don't need to adjust coordinates for your UI elements specifically for iPhone4.
If you have '#2x' images for retina display then system will automatically draw them appropriately in the frame you had for normal display.

What size images should I use in order to support the two iphone resolutions?

I have a few questions about screen resolution, that I'm not clear on. These questions assume they my app will be running on iOS 4.0 and up, and on either iPhone 3GS or iPhone 4.
Should the size of the splash image (default.png) be (960x640) or (480x320)?
Should the size of the app icon (Icon.png) be (57x57) or (114x114)?
What about other graphics that I may use in my app, such a graphic that represents a button? Should I always create these images for the higher resolution, and have the app scale them down? In other words, if I want a button image to be displayed on the 3GS that is 200x40 - should I create the image at 400x80, so that iPhone 4 can take advantage of it?
Thanks!
A good guide to this can be found here: http://mobile.tutsplus.com/tutorials/iphone/preparing-your-iphone-app-for-higher-resolutions/
In general you just create 2 sets of images. Your original and then a new one twice as big with #2x in the name. So for image.png at size 32x32 you would have one that is twice the resolution called image#2x.png at size 64x64. In your app just always use the image.png in Interface Builder and when loading in code.
There is no need to detect the device. These images will automatically be picked up by the OS and subbed in as necessary.
Provide both sizes (960x640 & 480x320) for the splash image using the #2x method described above
Provide both icons (57x57 & 114x114) using the #2x method
For our apps we use a combination of the #2x images and just Scaling the large images. (More information on this can be found in the above article) We use the #2x images for bar buttons, icons, etc. But for UIImageViews we often just use the Scaling. There can be a performance hit for doing this, but for most apps I'd say this is negligible. The savings in file size sometimes make scaling the only option.
Related Questions:
Retina/non-retina images in UIImageView
Making an app Retina Display friendly
You need to provide both if you want them to look nice. For example,
Default.png -> (480x320)
Amd
Default#2x.png -> (960x640)