How to add bottom constraint? - ios

I am using Xcode 8.I add UIView in bottom.I see is perfect in storyboard.
But when i run in simulator its doesn't look perfect. I don't know what the problem is.

I'm not sure if I understood your question correctly, but in Xcode you add constraints by ctrl+click+drag from the view that needs a constraint to any other view (or the layout margins). This may look like this:
ctrl+click+drag
On the size inspector (on the left side) you should then see all your constraints, so for example something like this: example size inspector with four constraints defined
This is where you can also edit the properties of your constraints.

Look for several things that can go wrong
Your UIVIewController's auto resizing subview is turned off.
UINavigationController's translucent property goes wrong.
Your top view height is fixed & some of your constraint are breaking and bottom constraint is one of them.
Your constraint priority is low, so breaking the bottom constraint.
in the console look for following:
Probably at least one of the constraints in the following list is one you don't want.
this indicates, some of your constraint conflicting each other, fix it.
If you insist on your question title, how to add bottom constraint, then here it is
NB::Hold the right click while dragging.

Related

Swift 4 - Issue with constraints on iPhone

I am having some major issues with my constraints, all I did was select add missing constraints and it looks fine in my storyboard and on an iPad like so,
But when I run it on iPhone, it looks like this:
What do I need to add to fix this issue...this is what I got so far:
Don't relay only on Add missing constraints , you have to make your edits after applying them
I see some constraints with leading
949,344 and 283+
and this may exceed width of some iphone screens
Simply remove any leading and trailing , and centerX the items with width constraints
also using UIStackView is good for the lower textfields
The easiest way to solve your problem with the constrains in my opinion for this type of layout is to embed your views in to Stack View. With Stack View you can easy center this views in to Screen by adding some costrains to the Stack View. With Stack Views if you need some adjustment you can do it only with few mouse clicks.
Select all your views
Click embed in the Stack View
Delete constrians that you don't need
Adjust alignment, distribution and spacing
Add trailing, leading and heigh constrian
Now it should looks good.

Xcode view hierarchy debugger - "prototyping"

What does the word "prototyping" mean in the view debugger? It's used to describe a constraint that I didn't add. In IB, the view in question (the upper-left onion image) has an intrinsic width, and its right edge is anchored. It shouldn't need any extra horizontal constraints.
In IB I was designing with a view having simulated metrics set to "Freeform" size, the debugger is showing the view on a 6S. I'm guessing the answer lies in the difference between the two, but can't fathom what's going on.
The added "prototyping" constraint is pulling the onion out of place, towards the left screen edge. Why was it added?
The 'prototyping' constraints are added by XCode Interface Builder when you don't supply enough constraints for it to determine what the layout should be. If you plan to add constraints later at runtime, which it sounds like you're doing, you can add constraints in IB and set them to be removed at build time.
Just add a constraint for the view's leading edge to superview (even though you don't want it), select the constraint in IB, and check Remove at build time.

iOS Swift, Constraint pushing view off sotryboard

I'm working on my first swift app and I found out quickly that I need to use constraints to properly layout my page. So far I'm running into two issue.
The first one is that after adding some constraints, my view is pushed off the screen on the storyboard, but it looks fine(outside of my second issue) in the Assistant editor.
My second issue is that on some phone sizes the constraints are causing the text fields to expand when viewed in the Assistant editor and on an iPhone 6s test device.
I've added some screen shots below. Any help with this issue would be really appreciated.
Each time you add a constraint in storyboard, it is not automatically applied to your working view. You may think it should be applied immediately, but try to think think like this. If you have a view, and you apply height constraint (for example) and if Xcode applied it automatically you would get a view of width 0, since you haven't applied width constraint. That's why you need to tell Xcode to update constraints explicitly.
So when you want to update constraints, select view you want to update and go to Resolve Auto Layout issues, and click on Update Frames. This is located in the bottom right corner of your storyboard. It looks like a small triangle between two lines. Here you can update all views or just selected views.
For the second issue, you need to apply fixed width constraint to your stack view, instead of adding leading and trailing constraints. By doing that stack view will have the same width on each device.

Autolayout - Why does "Vertical Spacing" sometimes attach to the opposite side of a view?

When I select "Vertical Spacing" in interface builder, I expect the bottom of the upper view and the top of the lower view to have a relationship. However, frequently what seems to happen is that the bottom of the lower view gets linked to the bottom of the upper view. Then at runtime the bottom view will have the wrong frame (after resizes, animations, etc.). Is there a way I can ensure that views are consistently linked bottom to top?
[EDIT]
Here's another example. I set a height of 419px. I select "Top space to top layout guide". But instead it puts a constraint for how far the bottom of the imageview should be from the top of the superview. Then I change the height from 419px to 374px, and the view has correct height, but a gap at the top.
I've noticed this many times (usually when attaching the top of something to the topLayoutGuide), and I've put it down to a bug in Interface Builder. It seems like the issue has gone away in the betas of Xcode 5.1
The only workaround I've found is to initially move your view away from the view you're attaching it to, and then create the constraint. In this situation, Xcode will usually do the right thing. Then manually edit the constraint's constant back to 0 (or whatever you want it to be).
Instead of adding vertical spacing, try by adding "Top spacing to nearest neighbor" constraint. Please refer attached image,
Hope this will help.
This issue is fixed in the latest versions of Xcode. You can now select which part of the constraint you want to attach to. It may attach wrong initially, but the constraint editing controls are much better now.

IOS Storyboard Constraining Every Subview to bottom of screen

This seems like it should be very simple, but I am having a terrible time trying to get every subview (they act like menu bars) constrained to the bottom of the parent view in the IOS storyboard.
There seems to be automatic constraints placed between the subviews that make them override the constraint I'm trying to set. I try to take these off, and then place the new constraints, but nothing seem to work as I loop over trying to reset constraints, over and over and over...
It should be very simple, set all of the uiviews to a particular width and length and set the distance between the bottom of the superview to be equal to 0. That's it.
The secret to happy constraint editing in interface builder is simple:
Don't do it
If that isn't possible, then:
Create your own constraints before trying to delete the system ones
Make judicious use of the pinning menu and editing constraints in the inspector
Don't drag and drop your views after you've added them - this causes interface builder to discard all constraints and set you up with a new set of "best guess" system constraints.
I've written more about this here but that's the gist of it.

Resources