Supporting all iphone sizes - ios

I'm trying to create a iOS app, but I'm stuck on the layout.
I created the home view, but now I see that it's not shown in the right way in the 4S simulator.
I tried with size classes, but it looks like 4S and 6, for example, are in the same size class, and so I can't set a different dimension for views.
My goal is to support all devices, also iPads. Can someone please tell me how to do it?

Size classes mostly used for separation between ipad, apple watch and landscape modes.In potrait mode iphone 4 to iphone 6 all phone device sizes are in same class(regular height and compact width).Autolayout has many different constraints to help you to fit interfaces in same class.You should consider horizontaly/verticaly align, equal width and aspect ratio constraints.They are so flexible for smaller size changes and help you to design adaptive layout.

You should use "Reset to Suggested Constraints" for all views in your View controller. You can also check the simulated metrics for all devices without compiling the the code.
For 4s and 6 by default the size is Inferred. You should try resetting the constraints to check this for iPad as well.

I am just sharing an idea
Option1:
I think You can try adaptive Layouts and in file inspector->simulated Metrics->size-> Inferred. It works in all devices it supports both landscape and Portrait.
Option2: Go for Visual layouts they are easy to understand and they work perfect in all modes of Portrait.

I am think that you use code Instead design in main.storyboard !
for ex: create button with code
(and use Ratio in your code)
by this way i create small app for iPhone & iPad
!

Related

Autolayout in iPhone Portrait Mode

I have to design an app for all iPhone size portrait mode only. I am using storyboard and setting constraints using storyboard itself. What makes me confuse is Size Classes. Since my requirement is iPhone portrait only, I am using Size Class compact Width|regular Height. My question is can I disable the Size Classes cause working only for iPhone portrait mode. If yes, then can I design with Size Classes disabled for all iPhone size. What is the right approach?
Intuitively, prior to size classes, storyboard UI was designed by doing a separate interface for each iPhone size. Since the advent of a broad range of device sizes, size classes have been incorporated. Considering that your app may have to run on older devices, there is still a difference in size between iPhones in portrait mode. Because of this, you would likely have to make a separate interface for each orientation, which I have not tried. I believe the correct approach would be to simply design for the size class that you selected.
If you are only making your application for iPhone portrait not necessary to use the size classes. You just have to set proper contract which are in the size indicator.
It's my opinion for it.
If you are developing for iPad and iPhone size class is the best option.
Size classes deal with the problem of multiple orientations(portrait and landscape) and different devices(iPhone and iPad). You cannot differentiate between two different screen sizes for iPhone using a size class. Similarly you cannot differentiate between iPad mini(portrait) and iPad Air(portrait) on behalf of size classes.
All iPhones in portrait has the same size class behavior i.e Compact(width) | Regular(height), be it 3.5", 4.0", 4.7" or 5.5". Similarly all iPhones in landscape has Regular(width) | Compact(height) size class. Size classes aren't the solution to the problem you are facing.
In order to handle multiple screen sizes for iPhone in portrait, the best bet would be to make use of autolayouts. Pin your views with the boundaries so that they will get stretched or contracted on different screens. Similarly bind your labels with the boundaries of their superview so that they will grow too. Also you can make use of aspect-ratio constraint that will allow to grow your view and images relative to the aspect-ratio of the element rather than increasing them horizontally to end up with an elongated look.
If you are new to autolayouts I will highly recommend watching the following sessions from WWDC2012:
Introduction to Auto Layouts
Auto Layouts by Example
Best Practices for Mastering Auto Layouts

Views in storyboard do not resize properly on iPhone 6

I've checked a lot of different websites and stackoverflow answers, and I'm still stuck.
I developed an app for iPhone and iPad targeting iOS 7.1. I have two storyboards, one for each device. The app only displays in portrait mode. I cannot seem to get the app to display full screen on the iPhone 6 simulator.
I've tried numerous things, I followed the advice linked here by adding a Launch Screen, setting the iPhone storyboard to auto layout and "use size classes", and . Not only does that not affect the size, but the Launch Screen doesn't seem to scale properly either. If I get it to fit the iPhone 6 it doesn't fit the iPhone 5 properly.
I've tried adding the proper launch images and I don't get any errors saying the wrong image resolution is present.
I've used the storyboard as a Launch Screen described here.
Now, when I switched to "use size classes" I could manually extend the objects in the views to match up with the size of iPhone 6 (I have not tested it for 6s) but that makes it extend past the iPhone 5 boundaries. The only thing I can think of right now is to create another storyboard and detect if it's iPhone 6, but I would really like some other ideas.
Here's what it looks like for iPhone 6:
And here's what it looks like on iPhone 5:
Best advice i can give u is
Use default size class , the classic 600x600 and then use Auto Layout
Or do the reverse, take a 3.5inch size VC and apply Auto Layout on it. Everything will present itself quite perfectly if you can apply the right constraints
Here is a link for an awesome Autolayout tutorial

Autolayout(xcode 6,swift)

In I phone 5s simulator its working fine! I have one label,one image view and one button.As you can click on the link and see the picture now so i tell you that I used my image view as a background and the label is in the middle and the button is in the lower middle so i want that to look same in all the devices. i don't know anything about constraints.I am using Xcode 6
https://drive.google.com/file/d/0B2z_d4wEKPEFLV9RNFVlR3A5SFppa0tJT2tiQkQwVVVVTDVz/view?usp=sharing
I suggest you to take a look at this youtube tutorial. I learned how to make the constrains by watching it. The tutorial teaches how to make the similar layout as you required.
Link: https://www.youtube.com/watch?v=RpMzEmF-xZM
Hope this is helpful~
Autolayout is the tool used to make UI look similar across all devices, you should try to learn it if you want to continue to develop IOS apps. The concepts are pretty basic and are used throughout other languages.
This tutorial is useful if you want to create the auto layout using storyboards.
This tutorial is useful if you are making the view programmatically. I tend to use code for auto layout but it is just a preference, storyboards is fairly simple so I would suggest that. If you are going to do it in code a is to forget setting the autoresizing mask into constraints to false. You have to set this property on all the views you want to use auto layout for.
view2.setTranslatesAutoresizingMaskIntoConstraints(false)
Background ImageView
Select Image ->Pin->Uncheck Constraints to margin-> select top,bottom,left,right.
Button
Select Button-> Pin->Uncheck Constraints to margin->select bottom,left,right,Height.
label
Select label->Align->Center horizontally and Center Vertically in Container.
Pin->Width,Height.
If it is working for iPhone 5 but not another layout then this is probably happening.
There are demensions in the centre of the lower tab bar of story boards
There are screen size settings in the story board and regular*regular is the only one that is universal to all orientations and sizes of the ios device. if you set constraints while viewing in regular by compact (landscape for 5.5 inch iPhone) then those constraints will only be apply to 5.5 inch iPhones in landscape and if you tried running on a smaller iPod it would be as if you never set the constraints. the constraints for the 5.5 inch iPhone would not apply to the small iPod
if constraints were made in compact by compact and you were viewing the story board in say regular by compact then you would get an error saying that things are misplace and will not appear in the same at runtime. view the storyboard in the same dimensions that you set the constraints and you should not have an issue.
There is an option to simulate the device you want to run on specifically in storyboard and it can be say only 5.5 inch iPhones or something, whatever device.
go to paul hegarty developing iOS apps with swift on iTunes you if you want to learn more. He is a good source.

Is using constraint/auto-layout on iPad a mandatory?

All iPad screens, iPad 1, iPad 2 ... , iPad Retina and Mini iPad have the same screen ratio. width/height or height/width or width:height
So, Why do we need to use constraints for the iPad views?!
I also believe that in interface builder when you select the view controller, you can view it as iPad or iPhone. there is many iPhone options but only one iPad option. you can do that by clicking the size drop down list in the Attributes Inspector.
Is there any of the iPad screens that have more or less screen points comparing to others? "Screen Points" not "Screen Pixels" if yes, Which one is that?
You don't have to use auto layout, but it's a good idea to. Once you understand it it's faster to work with, more flexible and very powerful for animations. You should also consider device rotation and usage for things like multi-tasking (ios9, use size classes too).
If you Design your Screens in Width Any / height any than your design will run on any iphone and Ipad Screen with autolayout. And it's a good practice too. if you want any change for iphone / ipad screen than you can remove that constraint for particular devices.add particluar constraint for particular devices.

Resize app designed for Iphone 6 to scale correctly in iphone 5s

Ok, here is the problem I have designed an application for iphone 6 screen without size classes and autolayout.
Looking like below in the storyboard. As you can see its simulated size is 4.7 inch.
It works perfectly when running on iphone 6 devices obviusly.
However when trying to run the app in other devices than iphone 6 it wont scale proportional.
My hope was that if I removed the lanuch screen images only keeping the iphone 6 size it would scale to fit other screens looking the same as if it where run on a iphone 6 only scaled up or down depenging on device.
My launch screen looks like this now
It does infact scale the app but it scales the app in wrong proportion making it looked chopped like this.
Iphone 5s version of the app looks like this
As you can see it scales correctly but the aspect gets wrong compared to the iphone 6 version below scaling correctly.
Here is an ipad version looking like the iphone 5s version scaling wrong.
It seems to me that the scaling works since I have removed all launch images except the 4.7 display (iphone 6) The problem however seems to be that it scales keeping the aspect of an iphone 5 in width making the iphone 6 display to wide.
I have tried to add launch images for all devices but the problem then is that I need to use autolayout and size classes to make it work.
Is there any way to for instance tell the scaling to keep aspect but use iphone 6 width and height intact without using size classes etc.
To make the question even more simple. Is there any way to scale an app made for strictly iphone 6 so resize to iphone 5s/ipad?
Any help is highly appreciated!
Well, the "trick" with removing the other launch images doesn't work, as you noticed yourself.. This automatic scaling only works from 4" to 4.7" and 5.5" and is only to support older apps on the new devices, not for general purpose "I am too lazy to support all sizes" use cases.. ;-) Apart from that, you should definitely support the native resolutions.
So, to answer your question: You can either just use Auto Layout. This is definitely the preferred approach - after all that's exactly the use case that it has been built for.
Alternatively, if you really don't want to or can't use Auto Layout, you either need to make sure to set your auto resizing masks correctly (e.g. "flexible width" on the stuff that needs to grow/shrink horizontally etc.), or adapt your frames manually in code (which partially defeats the purpose of IB).
If you didn't use Auto-Layout or Size Classes, your only hope is to programmatically change the positions/size of each element individually in the viewDidAppear or viewDidLayoutSubviews method of your LoginViewController. You would have to do it also on orientation change (if your app supports it).
It's a lot of work that can be easily be avoided by using Auto-Layout/Size Classes!

Resources