1
votes

Some background : I have a nested tableView in which I can have different types of cell ranging from map to images to key-value pair and more so I had to work with nested tableView which is hard to be achieved by section-row combination

I am using auto-resizing cells.

In my parentTableView I have set

parentTableView.rowHeight = UITableViewAutomaticDimension
parentTableView.estimatedRowHeight = 200

In my childTableView , I have set

childTableView.rowHeight = UITableViewAutomaticDimension
childTableView.estimatedRowHeight = 68.0

Here 68.0 is my cell size which is a custom XIB having two UILabel in vertical sort of orientation. Now when the labels are not multiple line, the tableView is appearing fine . But when i add multiple lines to the labels, the cells are getting clipped

enter image description here

But when I increase the estimatedRowHeight to say a greater value like 80, it is not getting clipped but displaying the content AND add some extra white space at the end

What I believe is happening is that it looks at the estimatedRowHeight value and number of cells that are to be displayed and calculates the parent cell size as per that . And when multiple lined label occurs it increases the size of the cell but the parent cell size has already been defined so it gets clipped

Can anyone please help me out i have tried a lot of fix but nothing is working.

1
It looks like some problem with your autolayout settings in xib/storyboard. Can you provide some sample project i.e. on github?Michcio
@Michcio It's a big project and i cannot cut out that part and reproduce it because there are a lot of dependencies. Can I just upload the XIB that i am using ?user121095
You can try, maybe it'll help to find an error.Michcio
@user121095 upload your cell xib & viewcontroller file so that I can helpAnand Yadav

1 Answers

0
votes

First of all, I would like to suggest that please avoid the nested tableView concept. You may facing glitch issue while reloading it and when data will be huge, it may cause UI blockage.

Coming to Solution, Please try the following solution: - Add constraints to each element as per your requirement except last UILabel. - Add top and bottom constraints (compulsory) with any other constraints (if you need). It will help the cell to understand the run time height of that cell. - In tableViewCell(_ heightforrow) method, put the height as return

UITableViewAutomaticDimension

func tableView(_ tableView: UITableView, estimatedHeightForRowAt indexPath: IndexPath) -> CGFloat { return UITableView.automaticDimension }