Reputation: 1709
I'm practicing with TableViewController
and custom TableViewCell
. I have made a question list & after clicking Show button it shows the question's options like this.
but removing spacing of question list view from above image I have wrote this code
-(void)viewWillAppear:(BOOL)animated{
self.tableView.estimatedRowHeight = 40.0;
self.tableView.rowHeight = UITableViewAutomaticDimension;}
and the output comes like this before and after clicking Show button.
but I'm trying to make my output with dynamically manageable the row height after clicking the Show button.
Constraints :
NOTE: I have gone through Using Auto Layout in UITableView for dynamic cell layouts & variable row heights
But haven't resolved my problem.
Thanks.
Upvotes: 1
Views: 158
Reputation: 9503
You constraints are not proper. And instead of using rowHeight
property use heightForRow
method because this property called once but this method is called for each and every cell
.
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
return UITableViewAutomaticDimension;
}
For constraints your every component in cell must have top, bottom and height. For anyone of the component, if you missed anyone of this constraint then there is defect is created in your UI.
For more details post your prototype-cell
screen shot and show the constraints you have given to them.
Edit
Tick on clips to bounds property of StackView
and its inner four button.
After doing this I get following output :
Reason:
StackView not let the inner content to be 0
.
If you still have doubt I have demo you can take it from me.
There is one more approach for this type of problems
show
button get the indexpath of button and load option cell in the table just after that indexpath.hide
button then remove that option cell.NOTE:
Upvotes: 2