I have 3 different views and view controllers. 1 is responsible for displaying some review text, it has a UIScrollView and a UILabel. Another is responsible for displaying comments, it has a UIScrollView a nested UIStackView. The third one, I want to combine the previous 2 and be able to scroll them them together, and it has a UIScrollView (the contained element at this stage can be anything).
I want to keep this separation because the review text will be displayed elsewhere, by itself or with other information as well and I've abstracted the comments so that the same code can be used with a different comment model to display different comments depending on the context; with this particular context being a discussion on the review text.
The end result I'm looking for is that review text and the comments can be scrolled together.
Naively, I've tried adding the view controllers as children and the views to a UIStackView within the UIScrollView and I ended up with two views that scroll independently, more or less. Which makes sense, but is not what I want. I'm finishing testing using UICollectionView and it doesn't seem to work (the child view controllers don't seem to get notified when the view appears, which is where I'm setting the UILabel's text for the review and building the nested UIStackViews for the comments). My next idea is to somehow 'rip' the content out of the views' scroll views and place it into the third's UIScrollView's container (probably a UIStackView). But before I do that, I wanted to see if there was an easier way to effectively merge these 2 scroll views (and their associated view controllers) into a third, containing scroll view (and its view controller).
UIStackView
. The key is to set the height of the "child scrollViews" to the height of their contents. That would stop them from scrolling independently. – DonMag