How to let Xcode know which asset to use for the target iPhone? - ios

I am designing an app for iOS in SWIFT. I have decided that the auto layout will be compact and will be only for iPhone in portrait mode. I wanted to clear up a few hiccups on designing buttons for the 2 different screen ratios: the first being the iPhone 4s and the second ratio being the iPhone 5 and above. Because the new iPhones have a taller height, does that mean I will need to design 2 different ratios of buttons, and if so, how do I use them in Xcode? For example here's the stock apple calculator;
link to picture: http://imgur.com/mkIBghD
As you can see the the buttons on the taller iPhone have a square shape. The buttons on the 4s are more stubby. What do I need to do in Xcode to let the app know which asset to use for the respective phone and how would I implement that in Auto Layout?
thanks

In order to do this you setup autolayout constraints. This will make the buttons change shape/size depending on the device. You do not need to have multiple assets because all the phones you are talking about have the same retina (2x) display.

You need to add three different sized images for a single Image Set in Images.xcassets . The sizes should be 1x for iPhone 4s, 2x for iPhone 6(It'll work for iPhone 5 too) and 3x for iPhone 6 plus.

Related

iOS auto layout support for all iphones?

I'm using autolayout storyboards for my ios app which is only for iPhone. When I submit, Apple reject it saying that the app should support iPhone 3.5 inch for ipad view on iphone resolution but making the UI for iPhone 3.5 inch is bit hard.
If I change it to support iPhone 3.5 inch onwards it gives bad view for iphone 5 inch. The contents are not centric there's long space for iphone 5 inch. What are the solutions?
Can I configure the settings to support iPhone 4 onwards?
or else Can I make two storyboards for iPhone 3.5 inch & 5 inches?
Yes, you can make 2 storyboards and switch them, depending on screen height, but why you can't adjust constraints for all iPhones screens? Usually this is possible.
One way for complex layouts - create constraint outlets and change them in code.
Another way - divide design to smaller UIViews, that contains elements, like container and set constraints between them.

Launch Screen Image size for all iOS screen sizes

I am trying to create a lunch screen image for my iOS app. But I am not sure whats the right size for it.
According to apple website for iPhone 6 the size should be 750 x 1334 (#2x) for portrait.
But my question is, how to create a launch screen image that will fit for all screen sizes such as iPhone 5, 5s, 6, 6 plus, iPads etc?
Whats the correct way of doing this?
Go to images.xcassets
there you can see launch image sizes.Just Enable iOS version from right side.
iPhone Portrait iOS 8:- 1242*2208 (5.5 inch)
750*1334 (4.7 HD)
iPhone Landscape iOS 8:-2208*1242 (5.5inch)
iphone Portrait iOS 7,8 :- 640*960 (#2x)
640*1136 (Retina)
iPhone Portrait 5,6 :- 320*480 (#x)
640*960 (#2x)
640*1136 (retina4)
But my question is, how to create a launch screen image that will fit
for all screen sizes such as iPhone 5, 5s, 6, 6 plus, iPads etc?
That will be very hard to do. The devices have different aspect ratios and the difference in size between say iPhone 5 and iPad Air is pretty big to use one image for all. If you want to use the classical launch screen with a screenshot, resizing one image won't look the same as the user interface on different devices. If you want a launch bitmap image you will need to supply all the necessary sizes.
Whats the correct way of doing this?
You can create either launch PNG image or launch screen as a storyboard.
For launch image, your project has an assets catalog. Either use existing or add new iOS launch image. The editor will show you all required sizes.
For a storyboard, your application probably already has LaunchScreen.storyboard. You typically won't create specific size or sizes here, but use auto layout that will resize the screen appropriately.

How to set auto-scaling on an app (optimized for iPhone 6's 4.7 inch screen) to fit iPhone 5 and 4's screen?

I have seen old iOS apps auto-scale to fit iPhone 6/6+'s large screen on iOS 8. I have recently developed an app which is optimized to display on iPhone 6's 4.7 inch screen. Apply auto-layouts would be lots of work because a lot of views are created programmatically so I am wondering is it possible to make an app auto-scale to fit smaller screens?
Use auto layout in code
Refactor your code to support different screen sizes
Refactor your code to size views as percentage of screen size

Distinct UITableViewCell / UICollectionViewCell metrics between iPhone 6 Plus and all other smaller screens

I have an iOS app that currently supports all screen sizes of iPhone and iPod touch (but not iPad), only in portrait orientation. The app supports iOS 7 and newer. My visual designer suggested increasing some metrics within certain UITableViewCell and UICollectionViewCell instances when displaying on the iPhone 6 Plus. For example, the image cell that shows an icon or a contact photo will be about 25% larger (by points) only on iPhone 6 Plus.
After reading this Adaptive Size Design article at apple.com, I see that iPhone 6 Plus does not have a distinct size class from smaller screen devices when in portrait orientation. Does this mean that I should detect the screen resolution and handle the iPhone 6 Plus-specific metrics in code instead of the xib? Or is there a way to handle this in the xib that I haven't come across yet?
In code, I could easily specify an alternate xib to load for iPhone 6 Plus, but would prefer to only have one xib to support all screen sizes and scale factors. This app might support iPads in the future, but not right now.
Yes: if you wish to display a distinct UI on the 6+ in portrait, you're going to have to do it programmatically, either by using UIScreen or UIDevice to identify when you're running on that hardware.

How to deal with iphone 6 size?

I launched my app on iphone 6 and 6 plus simulator. iPhone 6 plus uses #x3 images, but this have the same ratio. However, the iPhone 6 have a screen of 1334 x 750 (667 x 375) ... this sucks!
As you probably know, the app screen automatically fit to those new screen. But for the iPhone 6, images are bigger but they cannot be replaced (#3x is only for iphone6+).
How to deal with this new size?
I have to use autolayout only?
How to set the right screen size without automatically rescale this screen?
As Roger answered, you need to add the iPhone 6 and 6+ launch image
But you don't need to use autolayout. AutoLayout is one way of adapting to different screen resolutions, but the old autoresizingmask (springs and struts) is perfectly fine for most layouts. I use a combination of both as they each have pros & cons.
You need to do a couple of things:
Add a launch image for iPhone 6 and 6 plus.
adopt autolayout.

Resources