Size Classes & Plus Phone - ios

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.

Related

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

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.

Disable landscape orientation for iPhone only using size classes

I am using adaptive layout with size classes (iOS10).
For an iPad I want to support portrait & landscape views, but for iPhone I only want to support portrait. I don't want to rotate screen for compact height.
iPad is all fine and I have set-up the iPhone views using size classes, so I am thinking I need to somehow detect what size class will be transitioned to and disable rotation if it would go to compact height.
I can see a method called traitCollectionDidChange, but not sure if this is the correct time in the lifecycle to detect this.
There are a few related questions, but I don't see anything that covers this specific scenario.

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

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