Reputation: 2084
When I try to constrain the 4 buttons on the right of my calculator to the right side of the the view controller in the Storyboard, I get a bunch of red lines and conflicting constraint issues. However, I have no constraints placed on the right side of these buttons, and when I run it without updating constraints the pi, sin, cos, and sqrt trail off the screen. I also get a warning when I run it that says "Unable to simultaneously satisfy constraints." I am using Swift by the way.
EDIT: I don't understand how there can be conflicting constraints when there are currently no constraints telling the buttons on the right edge to clip to the right wall
Upvotes: 1
Views: 516
Reputation: 3016
Would be helpful to see a list of your constraints. Remember an item in Interface Builder using auto layout needs 4 things - a height, width, x coordinate, and y coordinate. If an item has all 4 of these it'll be happy. It could be that your x coordinate for one of those views on the right has two x coordinate constraints with the same 1000 priority.
You may not need that constraint on the right hand side at all. Also when you've got a red IB constraint often times the suggested fix works just fine with simple layouts. IB will display a red arrow like this:
Then if you've got conflicting constraints it will prompt you to delete some like this:
In your case you might see multiple constraints for "Horizontal Space".
What I find myself doing on occasion is removing all constraints and starting over. Doing this will remove any constraints you added in error or accidentally gave a bad value. The button kinda looks like a Tie Fighter with a triangle body. With one or more of the buttons selected, click this then choose "clear all constraints":
Also if you're wanting the buttons to occupy the majority of the visible area you might consider putting all of them inside a UIView.That way you could position and size the containing UIView and have the buttons follow suit.
Upvotes: 2