-
-
Save maxkramer/fc028c78bc2a92cab8eb to your computer and use it in GitHub Desktop.
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]; |
(So the log message about NSIBPrototypingLayoutConstraint indicates that IB is automatically generating a height=108 constraint that conflicts with the one you are trying to create.)
If you have enabled auto layout in the storyboard, then how come Document Outline in IB screenshots do not show the constraints? What version of IB is this?
Hang on. I know the answer to that one. let me think a minute.
For now, try this: in the view inspector, for the tableview, select the checkbox for the intrinsic size being "Default (System Defined)", and change it. You will see checkboxes that let you designate that the height and width are placeholders. Check those boxes. That will tell IB not to auto-generate those constraints based on the geometry values you see now in the view inspector. It tells it that the current values you are using are just "placeholders".
This might help but I don't think this will solve everything. If the whole project did not use AL, and then you enable AL, there may be more housekeeping to do to transition. I'm not sure off the top of my head.
The reason you don't see any of the blue constraints boxes I was expecting to see in the Document Outliner, is that although you've enabled constraints you haven't created any in IB. So IB is auto-generating constraints based on the current AR and frame values everywhere.
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.
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!
Yes, auto layout is enabled in the Storyboard.