Is there a rule for Regular and Compact in Size Classe? - ios

I am study Size Classes recently, and there is a form seems need me to memory:
As you see, I can not find the law(rule) of the Regular or Compact in the Vertical and Horizontal direction in defferent device.
Such as I have many doubt, such as :
why iPhone Landscape in Horizontal Size Class is Compact but iPhone 6p's Landscape is Regular?
Why iPhone Portrait's Horizontal Size Class is Compact?
I can not understand if there is a rule, so I can remember this form or understand this form here.

iPad is regular / regular (except in splitscreen mode).
Compact width distinguishes iPhone from iPad. Compact height distinguishes iPhone in landscape from iPhone in portrait.
The Plus devices are big enough with high enough resolution that in landscape they can contain the same interface as an iPad. For example, they have room for a UISplitViewController to display master and detail simultaneously. Thus they are exceptional.

Related

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.

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

How to make a different design for small iPhones and iPhone 6 plus using size classes?

Is is possible to make a different design in Interface Builder for iPhone 6 plus and other iPhones using size classes? I need only portrait mode.
According to some tutorials (http://swiftiostutorials.com/using-size-classes-xcode-6/) it seems that it should be possible. Also in IB Compact+Any seems to be for small iPhones:
and Compact+Regular for all iPhones:
But when I am trying to receive a different design it not works. For example how to hide a view for small iPhones and show it for iPhone 6 plus?
Sadly you can only do that for landscape (where the iPhone 6 plus has a different trait collection than the rest of the iPhone family).
The way it is worded in IB is kind of misleading. You are right in expecting the wCompacthRegular to overwrite the rule for wCompacthAny. The problem is that the iPhone 6 plus falls under the wCompacthRegular category too.
Printing a view's trait collection when running on an iPhone 6 plus proves this:
<UITraitCollection: 0x7f968ada42c0; _UITraitNameUserInterfaceIdiom = Phone, _UITraitNameDisplayScale = 3.000000, _UITraitNameHorizontalSizeClass = Compact, _UITraitNameVerticalSizeClass = Regular, _UITraitNameTouchLevel = 0, _UITraitNameInteractionModel = 1>
These two in particular:
_UITraitNameHorizontalSizeClass = Compact, _UITraitNameVerticalSizeClass = Regular
You can change/override the traits at runtime (i.e. tell a view "no matter what you think, I say you have a Compact height etc") but for your case I would just switch on the screen's height and hide views manually based on that information.
In portrait orientation, you cannot use size classes to distinguish between the iPhone 6 and 6+. You will have to do this programmatically by checking the screen height after your view loads.
The Human Interface Guidelines show that both phones have the same trait collection in portrait: Compact width/Regular height. The collection in your first image is Compact width/Any height, which includes Compact width/Regular height- that's why you're not seeing a difference if you install a view in one but not the other.
While not applicable to your case, it is worth noting that you can distinguish between the two devices in landscape orientation, as the 6+ uses Regular width/Compact height, but smaller phones use Compact width/Compact height.

Xcode Layout constraints: selecting divisions

I want to have two different layouts. The first layout must be applied to iPhone-3.5inch, and the second one to all the other device sizes. However, the layout I set for the compact width/compact height does not seem to take over the other layout even when I test with an iPhone-3.5inch. How can I make the first one be applied to a small device, while the other to the bigger ones?
according to documentation compact width/compact height is size class for All iPhone models except iPhone 6Plus In landscape mode.
If you want to know whether the device is with 3.5inch screen you must do it in code.

How is Apple showing more in the Messages app in portrait on the iPhone 6 Plus?

With the new iPhone 6 Plus, in landscape the phone can show more content than the normal iPhone 6 or its predecessors. This makes sense, as in landscape the phone identifies as having a "regular width" for its size class.
However, in portrait its' still compact width, regular height for the size class, regardless of which iPhone. How is Apple then showing more on the iPhone 6 Plus in portrait when there's no size class identifying it?
Are they hard-coding it based on the device's width? Doesn't that go against the whole philosophy of size classes?
They are using auto layout to force their labels to adopt the width of the screen. There's a good description of how to achieve this in this SO answer.
Apple have also used Adaptive layout to implement the landscape view on Mail for the 6+.

Resources