0
votes

I want to make height of a custom tableview cell to zero, which was created with autolayout. Basically I have container view added as subview to cell.contentview. Container view's top, bottom, left and right are pinned to content view's top, bottom, left and right. Under certain condition I want to make height as 0.

I iterated through content views's constraints and found this constrain causing the problem.

NSLayoutConstraint:0x1369d8670 UITableViewCellContentView:0x1369b1a90.height == 48

This constraint is added by default by tableview.

Things I Tried : I removed all subviews of container view. But this does not make cell height to zero.

Things I don't want to do:

  1. I dont want to reload entire tableview coz I will be having many rows with many subviews.
  2. I don't want to delete row

How can I set height to zero?

1

1 Answers

0
votes

You can reload particular row so it will call tableview's delegate method for height change heightForRorAtIndexpath. You can set the height 1 when you programmatically reload particular row. You can store temporary indexpath which you want to make zero.

Clip all the subiviews by clipsToBounds=YES

call [self.tableView layoutIfNeeded];