UITableViewCell
iOS Development
Swift
iOS UI Design
Table View Height

What is the default height of UITableViewCell?

Master System Design with Codemia

Enhance your system design skills with over 120 practice problems, detailed solutions, and hands-on exercises.

UITableViews are a fundamental component in iOS development, providing a mechanism to display a scrolling list of data on the screen. One of the core elements of a UITableView is the UITableViewCell, which is used to represent each row in the table. A common question among developers is: "What is the default height of a UITableViewCell?"

Understanding UITableViewCell Default Height

By default, the height of a UITableViewCell is determined by the tableView(_:heightForRowAt:) method of the UITableViewDelegate if implemented. However, if this method isn't explicitly defined, iOS uses a standard default height. This default value can differ based on the iOS version and the device's accessibility settings.

Default Height in iOS

  • Pre-iOS 10: Prior to iOS 10, the default height for a UITableViewCell was set to 44 points. This value was often suitable for standard or custom table view cells that contained simple, non-complex content, like a label and an image.
  • iOS 10 and Later: Starting from iOS 10, the introduction of Auto Layout and Self-Sizing Cells prompted a shift to more dynamic table cell sizing. By default, the rowHeight property of a UITableView is set to UITableView.automaticDimension , allowing the cell to determine its height based on its content. However, if you don't use Auto Layout, UITableView falls back to 44 points.

Factors Affecting Default Height

Accessibility & Dynamic Type

With iOS emphasis on accessibility, users can increase the text size globally through the Dynamic Type feature. This allows table view cells using Auto Layout to adjust according to the user's preferred content size. If a user has a larger text setting, the cells will automatically resize to accommodate the content, affecting the default design height.

Custom Cells

While the default is often enough for simple lists, many apps require custom cell layouts, which might involve multiple labels, images, or complex views. Using Auto Layout constraints within a cell helps ensure that your cells adapt their height based on content needs.

Implementing Custom Heights

While the default accommodates typical needs, customizing cell heights can enhance user experience by making views more tailored to content. Here's how you can adjust UITableViewCell height:

  • Ambiguous Layout: Utilize Xcode's View Debugger or logs (via po in LLDB) to identify ambiguous layouts when dealing with unexpected cell sizes.
  • Content Compression Resistance: Adjust horizontal and vertical compression resistance priorities if certain views do not resize as expected due to content.

Course illustration
Course illustration

All Rights Reserved.