ios 8 nested auto sized tables

2019-05-01 11:31发布

问题:

I'm pretty new to Auto Layout, so this may be an easy question to answer. I have two UIViewControllers which both contain UITableViews that need to auto-size their cells. I'm trying to use Auto Layout and the new iOS 8 auto-sizing table cells. There is a parent/child relationship between these tables: the parent table view will display the child's table view in its cells.

The child's table view seems to auto-size just fine (the cells at least). The problem is that the parent cell seems unable to determine the size of the child table view.

What I see in a debug session is that the parent cell appears to be truncating the child's view. To be more specific, when I inspect the view hierarchy, I can see that the child table view's cells are auto-sized correctly, but the child table view seems to be set to the size of the parent cell (or some sort of default value) and not to its contents.

I have a repro project that demonstrates the problem. I think it may have something to do with UIScrollView and Auto Layout. I've read other posts on this topic which seem related. If that's the case, I need a little help figuring out how to apply that to my repro project.