Different layout for the same size class and almost the same view's width across devices - ios

Situation on below image shows the problem. There are two devices: iPod and iPad Pro. On iPad Pro there is split view with my app on the right site. My app uses UISplitViewController for appropriate screen width.
Why it makes difference as you can see in the image below?
Is there a way to change constraints somehow depending on size classes or sth else excluding screen width?

Related

Choosing appropriate screen size to work with

I have got rather general question about making Adaptive Layout in iOS App.
When creating new project in Xcode you have ability to choose with which screen size you can start working:
I have noticed that if you place a square UIView on iPhone SE screen and then connect Leading, Trailing, Top and Bottom constraints - this view displays correctly on every other screen. But if you perform same actions on iPhone X, then this same shape would be corrupted on smaller screens.
So, my questions are:
Which iPhone screen size to choose, when starting making iOS app in
order not to face headaches with constraints on other screens and to
make pixel perfect UI?
If I receive design prepared for iPhone X screen, can I prepare it
firstly for iPhone SE screen and will it be displayed correctly on
bigger screens in this case?
What are screen sizes you use in your projects most frequently?
Actually there is no difference in choosing which 1 , what you need is to make your thoughts when making constraints to be generic , and that means every static width/height will appear similar in all devices , and every proportional 1 will look according to the device size , personally i like to use iphone 5 ( please forget about iphone 4 or you'll have to make the main view a scrollview because of the very small height of that device ) , also you can toggle the device to see how the constraints you set ( in the choosen 1 ) are look in the other device
You don't need to 'choose' a size. This is just a display setting and you can change it at any time to preview your layout on different devices.
You need to make your constrains in a logical way that will naturally adapt when change screen sizes.

Size Classes & Plus Phone

So all phones have compact width/regular height in portrait. Plus phones have regular width/compact height in landscape while others have compact width/compact height.
So the only in LANDSCAPE orientation you can distinguish a plus model phone.
Question
Is there a way to distinguish a plus model phone in portrait orientation?
without checking for:
Screen resolution
Screen scale
Device strings
NOTE:
Checking for screen resolution/scale, device strings are plausible, however trying to stay away from those. For example, Apple had to put Contact Icons for Favorites for iPhone Plus in Portrait. So there has to be a formal way to do this?
You are getting it wrong. The main purpose to make the adaptive layout is it can adapt to any screen size irrespective of device.
You should not think about these devices screen size while making layouts. You should be thinking of size classes.
If your layout can work in above size classes than it should work in respective phones. Also if you are looking for orientation but your app support the multitasking than your layout might not work with that.
Ideally, Your app should have layout that can work in any screen size because apple is releasing new devices with different screen sizes so your app should be compatible and work in every layout.
But that is ideal world. You can handle most of your layout with size classes. In some cases you need to handle the special scenarios.

different ui items alignment for tablet

I'm new to ios(android dev). I'm using storyboard, and autolayout.
To optimize application for tablet, i used sizes in storyboard regular width regular height.
I want to align ui items on ipad different than on iphone mode. For example, i have a table of textfields that occupy full width on iphone. On ipad i want to place two or three textfields in one cell. How can i make different ui implemetation for ipad, so the logic shoudl stay the same.
I watched https://developer.apple.com/library/ios/documentation/UserExperience/Conceptual/MobileHIG/LayoutandAppearance.html#//apple_ref/doc/uid/TP40006556-CH54-SW1
But there is no answer there.
Jenya Kirmiza,
Size Class is what you want :) Size classes were introduced with iOS8 in order to avoid the multiple storyboards for universal applications and yet provide an easy way for the developer to design differrent UI for differrent Devices :)
I expect you to know SizeClasses, In case you are not aware each device in its various orientation falls to one of the sizeClass defined by Apple.
One thing important to note here is that iPad in its both the orientation falls to Regular x Regular size class
Where as all iPhones other than iphone 6S and iphone 6s + will fall to
Copact Width x Regular Height - Portrait mode
Compact Width X Compact Height - Landscape Mode
Iphone 6s and 6s + falls to
Copact Width x Regular Height - Portrait mode
Regular Width X Compact Height - Landscape Mode
Now that you are equipted with the information of all size classes lets nail this issue down. When you open the story board at the center of the screen there is option to decide the size class :)
So go ahead open up your story board when you see it by default will be in wAny wAny mode What it means is whatever the components you add and add the constraint to it will be applicable to all the sizeclasses irrespectively.
Hence you see the textField added at the center of the screen appears center in all the devices may it be iPhone ot iPad.
For explaining Ill add two text fields named Firstname and LastName :)
Lets start adding textFields and constraints to them in storyboard keeping wAny wAny mode.
Now I have added two textFields one below the other covering the whole width of the screen in any any mode :) This will work fine for me in all iPhone devices :)
But I want to allign them side by side in iPad. Now we know that iPad belongs to Regular x Regular sizee class in both the orientation :)
So Simply change the size class in storyBoard
Now when you see you will see two textfields added one below the other already :)
Now select those textfields we want to align them differently isnt it :) So will have to remove the constraints already added to them :)
Now move them place next to each other add constraints properly :)
Thats it now run on iPhone and iPad :) You will textFields one below each other in iPhone and one next to other in iPad :)
iPhone Output :
iPad output :
Hope this helps :)

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

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.

Resources