im rting figure out how tableviews height change depending upon content in tableview. cant allow tablevoew go further bounds of superview. can have tableview anywhere in between bounds of superview, can shrink grow other stuff depending upon content. did set top, leading , trailing constraints left botton constraint out thinking scale tableview needed height didint work. idea?
[self addconstraint:[nslayoutconstraint constraintwithitem:_settings_tableview attribute:nslayoutattributetop relatedby:nslayoutrelationequal toitem:self attribute:nslayoutattributetop multiplier:1.0 constant:20]]; [self addconstraint:[nslayoutconstraint constraintwithitem:_settings_tableview attribute:nslayoutattributeleading relatedby:nslayoutrelationequal toitem:self attribute:nslayoutattributeleading multiplier:1.0 constant:20]]; [self addconstraint:[nslayoutconstraint constraintwithitem:_settings_tableview attribute:nslayoutattributetrailing relatedby:nslayoutrelationequal toitem:self attribute:nslayoutattributetrailing multiplier:1.0 constant:-20]]; //trying figure out constraint should [self addconstraint:[nslayoutconstraint constraintwithitem:_settings_tableview attribute:nslayoutattributebottom relatedby:nslayoutrelationequal toitem:self attribute:nslayoutattributebottom multiplier:1 constant:450]];
this have written im trying figure out bottom costraint should in order allow tableview grow contents size
you can have @ answer: https://stackoverflow.com/a/13574193/2082569
pasting solution here easy reference, calculating height of cells , setting tableview's frame-
cgfloat tableheight = 0.0f; (int = 0; < [_stepsarray count]; ++) { tableheight += [self tableview:self.tableview heightforrowatindexpath:[nsindexpath indexpathforrow:i insection:0]]; } self.tableview.frame = cgrectmake(self.tableview.frame.origin.x, self.tableview.frame.origin.y, self.tableview.frame.size.width, tableheight);
the thing thats missing don't want go beyond superview's bounds, can use min
method this-
min(self.view.frame.size.height, tableheight);
optionally can checkout answer, uses sizetofit approach: https://stackoverflow.com/a/24202699/2082569
hope helps.
Comments
Post a Comment