1

What are the default cell, section header, and section footer dimensions (width, height, left/right margin, top/bottom margin) for a UITableView in the grouped style?

I already know:

  • Cell height: 44px, same as always
  • Section header height: 22px (from this answer) - myTableView.sectionHeaderHeight returns 10, but I can tell that's not right by looking at it when I set section titles.

My reason for asking is that I need to compute the expected total height of a grouped-style UITableView for returning from contentSizeForViewInPopover. But if I'm asking for the heights, I might as well ask for the widths for future reference.

Community
  • 1
  • 1
Tom Hamming
  • 10,577
  • 11
  • 71
  • 145

1 Answers1

2

doesn't storyboard tell you the section header's and footer's height? It does tell me based on the screenshot below:

Section header and footer height when Cell set to **GROUPED**

Fig 1: Section header and footer height when Cell set to GROUPED

Section header and footer height when Cell set to **PLAIN**

Fig 2: Section header and footer height when Cell set to PLAIN

The section width depends on your application coding. If you are using the UITableViewController, then the width would be the screen size (depending on iPhone/iPad). If you are having a UITableView within a UIView, then your width would be as you sized it.

Also, the cell height (44) you mentioned is it's default settings. If you are using custom cell, then each cell height could change.

With regard to the cell width, some guy measured it and posted it on his blog. However, if you want to have custom width, then this post on SO will be helpful: How to set the width of a cell in a UITableView in grouped style

Community
  • 1
  • 1
Steven
  • 974
  • 6
  • 18
  • I'm not sure I believe what it says. The header (where it says "Prototype Cells") looks bigger in grouped style than it does in plain style, and yet the numbers are reversed. It looks like 22 for grouped and 10 for plain. Also, is there any spacing between a grouped cell and the section header below it, besides the section footer? – Tom Hamming Sep 25 '12 at 19:35
  • Good question with regard to the "reversed" value. I can't answer why this is so, but it seem this is how the SDK gives me. I tried with the `heightForHeaderInSection` method to manually set the values to both 10 and 22 when running different mode. When 10 is used, both "Grouped" and "Plain" is off. When 22 is used, "Plain" looks like default, while "Grouped" looks a bit squeezed. It seem that when the you don't explicitly set the values for "Grouped" mode, the SDK sets it as 10, but renders it between 25-30. Strange, but true. – Steven Sep 26 '12 at 12:50
  • This maybe a possible bug. As per this SO post ([Default height for section header in uitableview](http://stackoverflow.com/questions/1200438/default-height-for-section-header-in-uitableview)). The answer by @paulthenerd says otherwise, but the comments seem to conflict on what the value is. For me, i see the values as per the screenshot. I would file a bug with apple on their SDK and see what they have to say. (IF you happen to file a bug, could you please link it in comment here. I'd like to know the result of it) – Steven Sep 26 '12 at 12:53
  • @Mr.Jefferson FYI, I filed a bug with Apple. But since this is proprietary stuff, I doubt they will get back to me and tell me how and when to expect to get result on this. – Steven Sep 28 '12 at 12:39