AutoLayout TableView issue with iPhone 6 and 6 Plus - ios

I have 7 labels on a cell in TableView in Landscape mode and I have set the Top Space and Leading Space on each. My issue is it is working fine with iPhone 5 screen it fit well but I get and empty space with iPhone 6 and 6 Plus screen on the right place. How I can fix that with the constraint?
Example:
iPhone 5:
iPhone 6

Please check this youtube link https://www.youtube.com/watch?v=WTMpJJ9Ofm8
In this link it is showing how to arrange vertical spacing.
You can apply same logic to "Trailing Space to Container Margin" for equal spacing. By changing the multiplier value of the constraint you can change the spacing.

Related

Add constraints to side by side four buttons

I want to add constraints to side by side four buttons. I've tried many methods on Stackoverflow and different sites, but the result is always like the picture. No problem with screens like the iPhone 11 Pro Max. Problems occur on small screens like iPhone 8.
This is xcode design screenshot (iPhone 11 Pro Max)
This is iPhone 8 screenshot
I selected them all and gave the top, right, left, height, equal width, equal height constraints.
I selected all of them and added top, right, left and height constraints. When I add Stackview, the third row gets corrupted.

Different constraints on iPhone 7 plus and other iPhones

I'm using UiTableView with static cell's and right detail table view cell style and I found that on all iPhone's except iPhone 7 plus leading space to left label equals 16 and on iPhone 7 plus it equals 20.
Screenshots of same cell in different iPhones:
I need to create custom cell with label that must have same leading spacing and I thought I can use size classes for it, but how if all iPhones have regular height and compact width in portrait mode (app use only portrait mode). I know that this problem can be solved programmatically, but there is must be some way to solve it via interface builder.
Screenshots of my custom cell and right detail style cell on iPhone 7 plus (my custom cell at the top have leading constraint equals 16, but it have to be 20 for 7 plus):
This is due to the margin of the top level view, which is set by the system to the values you described. You can override the margins of the view to be the same on all devices.

Change vertical space constant between iPhone sizes in Xcode or in Swift

I have a text two text fields and a button, it looks great on the iPhone 4 and 5 but not on the 6 and 6 Plus, it stretches to much because the keeps the constant stays the same of course.
Is there a way to increase it on the 6 or 6 Plus and keep it the same on the 4 and 5. Im using a vertical stack view and the bottom constraint is linked to the top of the button underneath it.
This is okay
This size I want to maintain
Still stretches
WHY!?
Just try giving fixed height to vertical stackview, if you want it's subview's to have same height if screenSize grows.

Custom UITableViewController cells won't auto allign

I have some custom cells in a UITableViewController that I've used constraints to set a label to align to the left margin with a a trailing space of 8 and a switch to align to the right margin, also with a trailing space of 8. This looks great on iPhone, but it does not align properly on iPad. Here's what it looks like.
iPhone:
iPad:
How do you set the margin to automatically change based on the screen size so it doesn't look so weird on iPad?
Absolutely nothing I tried would fix this. It turns out that there must be some bug in iOS9/Xcode 7, because I was only able to fix the issue by downgrading my devices to iOS 8 and Xcode to Xcode 6.

NSAutoLayoutContraint for iPhone 6Plus

Following is an image from iPhone6 having a simple view.
Constraint details are as follows.
But on iPhone 6 Plus, It starts getting margins from left & right.
Very easy to notice by looking at space before text 'Carrier' & space after battery icon in given images.
Question 1: Why do we add -16 as margin to leading and trailing space when adding a constraint to main/parent/super view?
Question 2: Why -16 margin works only for iPhone 6Plus & not for other phones?
Unselected Constrain to margin when you set your constraints
uncheck the "Constrain to margin" from constraint selection because this is a new feature of iOS8.

Resources