Search code examples
iphoneuitableviewuiviewuiscrollview

Dynamically set UIView size depending on height of grouped table view


Setup: I have a UIView with a scroll view nested within it. Within the scroll view I have a label, uiimage, and a tableview (grouped). The label, uiimage, and tableveiw are populated by a webservice. The last section in the grouped table view contains text that will never be the same and could be as long as 5 characters to 250+. Also, this view is pushed from a basic tableview (so it has a navigation bar. If that matters at all).

Expected: The uiview should extend in height depending on the height tableview extends to. Then I will be able to set the scrollview to accommodate the height I need to be able to scroll.

Problem: I'm not quite sure how to approach the issue. I really only know how to change the height to fixed values, which will not work properly in almost any scenario.

Am I using UIScrollView incorrectly? Do I need to resize the UIView at all?


Solution

  • Turns out I had to create a UIView programmatically and set it as the header of the UITableView. It works perfectly now. :)