dimanche 1 février 2015

Resizing Table Header View with Nested Table

I have a view controller that contains a tableview. I have inserted a UIView to act as the headerView for this table using storyboards. Inside this headerView I have a another table view, UIImageView and a UIView. The nested tableView will contain between 2 and 4 pieces of data so this can vary. Here are some pictures of my setup.


enter image description here


The problem: I know the specified height for the nested table view cells. Therefore I know the maximum size the headerView and the content size can be and I can define that just fine. Here is a screenshot demonstrating this: (The "One" cell is the parent tableView cell.)


enter image description here


What I'd like to be able to do is when I don't have 4 cells in the nested table, say 2 or 3, I'd like to be able to resize everything to fit proportionally on the screen. I attempt to achieve this by calling the code below when I have my data loaded.



[self.nestedTable sizeToFit];


However, calling size to fit adjust the nested table properly but seems to have no impact on adjusting the height of the headerView and the view below the nested table. Here is a screenshot showing the result.


enter image description here


What I'd like ideally, is for everything to adjust proportionally to the nested table view size. I realize that this is most likely a constraint issue but I'm kinda stuck on how to get this set up just right. I'm using purely interface builder and would like to keep it that way if at all possible. Any help would be appreciated.




Aucun commentaire:

Enregistrer un commentaire