I'm struggling with wired kind of problem. I have UITableView
with one cell. This cell is only holding containerView with childViewController
(second tableView
). My problem is that, first tableView(parent) must have UITableViewAutomaticDimension
row height but it doesn't work (It dosen't know correct size of that cell with second tableView
). How to get correct size of second tableView
) ?
Second tableView ( inside Cell
) have scrollingEnabled turned off ( tableView.scrollEnabled = false
), first tableView must have correct size of second tableView in order to provide correct scrolling experience.
Since a UITableView
inherits from UIScrollView
you can use the contentSize
property to get this information. This is how the scrollbar works on the side.
I have done a similar thing before (long ago), so the following is somewhat hazy/ irrelevant/ unessecary. There might be some gotchas with unknown/unrendered cell heights in the embedded tableview. I rememeber having to set the tableview height to a large number (forcing all cells to render) fetching the contentSize
then resetting the tableview height to the contentSize.height
.
Are you shure you really need second table view? If you have just one cell probably you don't need it. I recommend you to calculate table view height as the summ of it's cells heights. If cells of embedded table view have constant height it could be simple. In other case you also could calculate cells height.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.