2

I'm using storyboard(XCode 6.3) with auto layout in my project, suing the size classes Wcompact hRegular. I'm not able to set the height of the UITableView Header height dynamically according to the content.

Babu
  • 39
  • 1
  • 2
  • This link may help you http://stackoverflow.com/questions/18118021/how-to-resize-superview-to-fit-all-subviews-with-autolayout/18155803#18155803 – Leo Jun 24 '15 at 07:16

2 Answers2

0

You can reload section with this header when you change it's content

Something like this:

- (void) shouldUpdateSections:(NSIndexSet *)sections
{
        [self.view.tableView reloadSections:sections withRowAnimation:UITableViewRowAnimationAutomatic];
}

Call this method when you need to update your header.

To increase performance, you can make separate section only for this header.

Doro
  • 2,413
  • 2
  • 14
  • 26
0

Handling the height of a UITableView header is very similar to handling the height for a cell. When you want to make it dynamic, you need to call layoutIfNeeded for the header in the tableView:heightForHeaderInSection: method and return the resulting frame's height.

An excellent, in depth, description of this can be in this StackOverflow question.

Community
  • 1
  • 1