First of all, I must mention I have duplicated the constraints in a new project and have not been able to duplicate the problem. The problem occurs in a complicated storyboard project I've been working on for months.
For simplicity's sake, this is basically the issue:
I have a Container View inside of the default View inside of a View Controller. The Container View has constraints to the Top, Bottom and Trailing edges of it's superview. I have two "equal widths" constraints connected between the superview and container view. One is equal to the superview, the other is proportional to the superview with a 0.9 multiplier in the constraint.
I have a button superimposed on top of the container view which alternates between the 2 "equal/proportional widths" being active (I've currently deleted all the other objects in the View Controller for simplicity, to try to isolate what is causing the problem...
When the button switches the "equal widths" constraint to the 0.9 proportional width constraint, it "pushes" the container view away from the trailing margin (by 12 points), while it also shrinks the container view by 10%, as desired.
I've been working on this for hours, so far to no avail... out of desperation, I added an extra trailing edge constraint to switch on and off, with an extra 12 points to compensate for the shift when the proportional width is switched on. The default trailing (to superview) constraint is set at -20, as I increased it to -30, -31, -31.5 it got closer and closer to looking right, but when I put it's constant at -32, it jumped again, about 12 to 20 point, off the edge of the trailing margin! I know this is not a good way to try to solve this problem, but I wanted to mention it, in case it may be a clue for someone more knowledgable than me as to what is causing the problem..
Thank you for any help you can offer!
UPDATE:
The problem seems to be stemming from a conflict in the VC embedded in the container view. The Height of the embedded VC was 720, while it's container was 720... but even after I change these Heights to match, either way, I get the same problem...
The problem seems to disappear if I delete the embedded VC and just use the container view, but this is not a solution since I need the content of the embedded VC...
One last note, I have a similar method in place with a button press which changes the height of the embedded VC, but with no problem..
I solved it!
So, as I suspected in my update, the problem stemmed from something not syncing up in the constraints between the container view and it's embedded view controller. In the container view, as mentioned above, there was a constraint for the trailing edge of the superview and 2 for the width I was switching between with a button. The embedded view controller's view was had a leading constraint to it's superview. Once I deleted that and switched it for a trailing view as well, the problem was solved!
Lesson learned: If you are going to alter a container view with multiple width or height constraints, make sure have the same side constraint in the container view and the embedded view's contents (top or bottom for y-axis, leading or trailing for x-axis).