Created
October 14, 2014 18:46
-
-
Save maxkramer/fc028c78bc2a92cab8eb to your computer and use it in GitHub Desktop.
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
NSLayoutConstraint *widthConstraint = [NSLayoutConstraint constraintWithItem:self.tableView attribute:NSLayoutAttributeWidth relatedBy:NSLayoutRelationEqual toItem:self.view attribute:NSLayoutAttributeWidth multiplier:1.0 constant:0]; | |
NSLayoutConstraint *heightConstraint = [NSLayoutConstraint constraintWithItem:self.tableView attribute:NSLayoutAttributeHeight relatedBy:NSLayoutRelationEqual toItem:self.view attribute:NSLayoutAttributeHeight multiplier:1.0 constant:-CGRectGetHeight(self.searchBar.frame)]; | |
NSLayoutConstraint *leftConstraint = [NSLayoutConstraint constraintWithItem:self.tableView attribute:NSLayoutAttributeLeft relatedBy:0 toItem:self.view attribute:NSLayoutAttributeLeft multiplier:1.0 constant:0]; | |
NSLayoutConstraint *bottomConstraint = [NSLayoutConstraint constraintWithItem:self.tableView attribute:NSLayoutAttributeBottom relatedBy:0 toItem:self.view attribute:NSLayoutAttributeBottom multiplier:1.0 constant:0]; | |
[self.tableView setTranslatesAutoresizingMaskIntoConstraints:YES]; | |
[self.view addConstraint:widthConstraint]; | |
[self.view addConstraint:heightConstraint]; | |
[self.view addConstraint:leftConstraint]; | |
[self.view addConstraint:bottomConstraint]; |
I find erasing ~/Library/Developer/Xcode/DerivedData/projectname-blahblah/ often works wonders.
I've made the suggested changes, which didn't affect the layout either. I have however tracked back the IB generated constraint to being a result of the Y value of the table view not being 0 initially. The fix for this would of course be setting the Y value to 0, but this didn't get rid of the constraint.
Ha, I had a derived data exterminator from Alcatraz, but I haven't got around to reinstalling it yet!
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
It sounds like it will work as the constraints shouldn't be generated in that case, I just need to get past Xcode (6.0.1) crashing when I check the checkboxes for the table view.