Last active
January 22, 2016 22:08
-
-
Save thornpig/827ef418ab523fa8511d to your computer and use it in GitHub Desktop.
Sequence of constraint activation/deactivation matters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-(void)updateConstraints | |
{ | |
[super updateConstraints]; | |
if (self.binaryFiles.count > 0) | |
{ | |
//deactivate first, then activate, then change constant | |
[NSLayoutConstraint deactivateConstraints: @[self.attachmentButtonConstraintHeight]]; | |
[NSLayoutConstraint activateConstraints: @[self.attachmentButtonConstraintAspectRatio]]; | |
// self.attachmentButtonConstraintHeight.active = NO; | |
// self.attachmentButtonConstraintAspectRatio.active = YES; | |
} | |
else | |
{ | |
[NSLayoutConstraint deactivateConstraints: @[self.attachmentButtonConstraintAspectRatio]]; | |
[NSLayoutConstraint activateConstraints: @[self.attachmentButtonConstraintHeight]]; | |
//changing constraint constant will trigger recalculation of layout and constraints conflict warnings if there are any. | |
self.attachmentButtonConstraintHeight.constant = 0; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment