samedi 30 août 2014

Unable to simultaneously satisfy constraints when setting them programatically


Vote count:

0




In my storyboard I set the following constraints.



left side constraint for a view = 9;
right side constraint for a view = 9;
(so I have 9 pixels space on both sides)


These constraints are set as constants in my VC.



confirmLocationViewLeftsideConstraint
confirmLocationViewRightsideConstraint


Now when my app loads I want this view off screen and then animate it on screen so I set the constraints via code.



self.confirmLocationViewLeftsideConstraint.constant = 400.0f;
self.confirmLocationViewRightsideConstraint.constant = -409.0f;


But this causes the app to crash with the following error:



Unable to simultaneously satisfy constraints.
Probably at least one of the constraints in the following list is one you don't want. Try this: (1) look at each constraint and try to figure out which you don't expect; (2) find the code that added the unwanted constraint or constraints and fix it. (Note: If you're seeing NSAutoresizingMaskLayoutConstraints that you don't understand, refer to the documentation for the UIView property translatesAutoresizingMaskIntoConstraints)
(

"<NSLayoutConstraint:0x175f1bb0 H:|-(400)-[UIView:0x175f0080] (Names: '|':UIView:0x175f1be0 )>",
"<NSLayoutConstraint:0x1761a6b0 H:[UIView:0x175f0080]-(9)-| (Names: '|':UIView:0x175f1be0 )>",
"<NSAutoresizingMaskLayoutConstraint:0x1b387bf0 h=--& v=--& H:[UIView:0x175f1be0(320)]>"
)


To me this is saying you can't set the confirmLocationViewLeftsideConstraint to 400 when the right is 9. But my next line of code above is going to set the confirmLocationViewRightsideConstraint to -409 so it should work, but I can't set both of these at the exact same time.


Is there a better way to achieve this sliding a view on and off? Or a better way to set them in code? I need to set the layout constraints in storyboard as I its a very detailed View with over 70 constraints to keep spacing.



asked 1 min ago

jdog

1,738






Unable to simultaneously satisfy constraints when setting them programatically

Aucun commentaire:

Enregistrer un commentaire