0

I've 3-5 dataSource and in ViewDidLoad() I've mentioned the property for dynamic cell height:-

  [self.tableView setEstimatedRowHeight:40.0];
  [self.tableView setRowHeight:UITableViewAutomaticDimension];

but the tableview don't update accordingly.. first two-three cell shows contents in good way but as soon as I scroll the tableview, cell gets compressed and then cell shows half of the content.

UPDATED

screen of customCell is tableViewCell andConstraints Are:tableViewCellConstraint I have a UIView in cell and label and a uiimageview inside the view

More Update::

I think its coz i'm also using an empty cell to have a space between two cell and in the delegate method for i doing this

-(CGFloat)tableView:(UITableView *)tableView estimatedHeightForRowAtIndexPath:(NSIndexPath *)indexPath {
return 20.0;
}

 -(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
if (indexPath.row %2 == 0) {
    return 15;
}
return UITableViewAutomaticDimension;
}
  • Use customcells. – Developer Jun 13 '17 at 11:39
  • https://stackoverflow.com/a/43556505/3236890 this may help – dip Jun 13 '17 at 11:40
  • I dont think number of Datasource has any effect on cells height. AutomaticDimension will work if the components either have intrinsic sizes or have height constraints set. I believe you are messing up with autolayout constraints hence cell is compressed. Post the cell xib with constraint. Will let u know the issue – Sandeep Bhandari Jun 13 '17 at 11:45
  • have a look to updated post.. I've mentioned the details – Navanindra Vats Jun 13 '17 at 12:08
  • uiview constraints are:: Top,Bottom,Trailing and Leading 0 to cell contentview – Navanindra Vats Jun 13 '17 at 12:13
  • @NavanindraVats What are the constraints that are given for the divider UIImageView? – Aravind A R Jun 13 '17 at 12:19
  • for that its leading trailing and botton to 0 with height 3 – Navanindra Vats Jun 13 '17 at 12:23
  • need more opinion on the updated post... please consider **more Updates** empty cell are loaded at even index – Navanindra Vats Jun 13 '17 at 12:30
  • after going through the various post and the one linked in the comment.. I'm getting this warning:: [Warning] Warning once only: Detected a case where constraints ambiguously suggest a height of zero for a tableview cell's content view. We're considering the collapse unintentional and using standard height instead. – Navanindra Vats Jun 13 '17 at 12:37

0 Answers0