[ACCEPTED]-What is the default height of UITableViewCell?-uitableview

Accepted answer
Score: 365

It's 44 pixels. Definitely. I'll never forget 4 that number.

44px is also the default height 3 for UIToolbar and UINavigationBar. (Both 2 switch to 32px when autorotated to landscape 1 orientation.)

Score: 26

If you want the default dimension on any 4 device you can use: UITableViewAutomaticDimension

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {

    return UITableViewAutomaticDimension;
}

Although 3 44 pixels is currently the default this 2 is a useful method if your app relies on 1 having the default value set.

Score: 16

When style = UITableViewStyleGrouped, the default height of the top & bottom 3 cells is actually 45.0f (not 44.0f). And, if the grouped 2 table is only one row the cell height will 1 be 46.0f.

Score: 11

If you want to calculate this on the fly, just 4 allocate a dummy table cell and read off 3 its height

UITableViewCell *cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"Cell"];
int height = cell.frame.size.height ;

This way you defend against changes 2 in future versions of iOS, although I suppose 1 that is unlikely.

Score: 3

"When style = UITableViewStyleGrouped, the 5 default height of the top & bottom cells 4 is actually 45.0f (not 44.0f). And, if the 3 grouped table is only one row the cell height 2 will be 46.0f." It's wrong!! 44.0f in fact! I 1 just test it!

Score: 3

In Swift 4 and Swift 5 simply use:

UITableView.automaticDimension

Using 44px won't suffice 2 because it will vary with different screen 1 pixel densities.

Score: 2

That sounds about right. But to be sure 7 you could load up Interface builder, put 6 in a UITableViewCell into the project then 5 check the size properties in the Inspector 4 window. I do not have my MacBook with me 3 right now so I cannot check. But if you 2 don't get a better answer from someone, that 1 is how you can check for yourself.

Score: 0

On iOS 12 the default height on iPhone X 7 like devices (X, XS, XS Max, XR) is 49pt.

Other 6 devices on iOS 12 still have 44pt as default. It's 5 a subtle difference, but it feels like a 4 good improvement in direct comparison.

If 3 you won't believe me, measure for yourself 2 in this screenshot (don't forget to divide 1 by 3)... ;)

More Related questions