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.
Related
I'm currently learning about auto layout and trying to setup some table cells to show the same across devices
The layout shows correctly across iPhone devices, but on iPads its stretched.
I believe I've narrowed it down to the trailing constraint, when I remove it it displays correctly on both device types but Xcode throws a missing constraint warning.
The constraints are using less than or equal, which works fine on iPhone but doesn't display correctly on iPad. iPad works if I use more than or equal, but this messes iPhone up
These are the constraints
This is how it should appear on both devices.
But this is how it appears on iPads
The reason you are getting a wide text field on iPad is because you're constraining the "Partial Bag" text field to the trailing edge of the cell.
Without looking at your actual Storyboard, not sure why you're getting constraint conflicts.
This is how I set up your cell, and have no issues (other than the known bug with text vertical alignment in IB when laying out rounded-border text fields):
Note that I gave Full Bag a Width of 32, and constrained the width of Partial Bag to be equal to Full Bag. No constraints to the Trailing edge of the cell's content view.
The result, in Portrait and Landscape orientations (which will, of course, layout similarly on an iPad):
You should set up a width constraint on both UITextFields. That way, the first (and second) one won't stretch. Another option would be to make the trailing constraint of the second UITextField be equal or greater.
I tried stackView as a newly swift dev, they are really convenient for layout related issue but, I still have a strange behavior on the iPhone 6 plus screen (see picture below)
3 image are in a stackView
StackView is in a cell, who is in a tableview obviously.
StackView constraint are set to be top,left,right 0 to the cell and 80% of the cell height
here is the result :
Result on iPhone 6:
Result on iPhone 6 plus
EDIT:
the miss-sized view happen only on iPhone 6 plus and not on iPhone 6S plus
with a constant of +14, in my case, on the cell percentage, the issue disappear (but size are no more in my design guideline)
thanks
Have you tried constraining the three images to have equal heights?
Set equal widths across images or set content hugging and content compression priorities for images so it knows how to size the stack. In my opinion the only way here is to make them equal width.
Otherwise you will always have some sort of constraint resolution based on hugging/compression values which even if the same will give ambiguous layout or if not the same and not ambiguous, will produce difference in sizes in certain cases. Equal width on the other hand should guarantee the width.
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.
I have a UIView in my iOS app that holds a graph. I have fully constrained the UIView in Interface Builder but yet when I view the page on my iPhone 6 the graph is a nice large size but yet when viewed on an iPhone 4s, the view appears much shorter to the point where it's uncomfortable to look at.
The constraints are as follows:
As viewed on an iPhone 4s:
As viewed on an iPhone 6:
How can I adjust the constraints so that the iPhone 4s UIView has similar proportions to that of the iPhone 6?
There might be some conflict in the constraints in 4S.
For this UIView, if the superview is fixed in terms of size, then only 2 of the following constraints need to be set.
align top to superview
align bottom to superview
height equals 150
Or if the superview is not fixed in size, then the superview constraints might have conflict with the tableview down below. try to set the tableview height using percentage, not the fix number?
My app displays correctly (as I've designed in IB and programmed in the code) in iOS 7:
On iOS 8, the exact same code at the same screen size displays this:
The height of the cell contents is different. Auto layout is on and the cell contents are completely tied to the bounds of the cell via leading/trailing/top/bottom constraints. I've heard about the new auto-size in iOS 8, but in my nib, the cell is not set to auto height, it has an explicit height defined. Why could this happen?
I've figured out the solution. Xcode 6 automatically adds spacing constraints to margins, instead of superview. I haven't figured out what they mean by margins, but if you hold option key when adding constraints, those margins change back to superviews, allowing you to add regular constraints to superview.