What's the correct way to have a self sizing cell in a UITableView?
Asked on 06/22/2025
1 search
To create a self-sizing cell in a UITableView
, you should ensure that your cell's content is set up to automatically adjust its size based on its content. Here are some steps to achieve this:
-
Use Auto Layout: Ensure that all the subviews within your cell are properly constrained using Auto Layout. This means setting constraints that define the size and position of each subview relative to each other and the cell's content view.
-
Dynamic Type: If your app supports Dynamic Type, make sure to set the
adjustsFontForContentSizeCategory
property totrue
for anyUILabel
or text-based component. This allows the text to resize according to the user's preferred text size settings. You can learn more about this in the Get started with Dynamic Type session. -
Set Estimated Row Height: Set an estimated row height for your table view. This helps the table view to calculate the content size more efficiently. You can do this by setting the
estimatedRowHeight
property of theUITableView
. -
Automatic Dimension: Set the
rowHeight
property of theUITableView
toUITableView.automaticDimension
. This tells the table view to use the auto layout constraints to determine the actual height of each cell. -
Content Compression Resistance and Hugging: Adjust the content compression resistance and content hugging priorities of your views to ensure they expand and contract as needed.
By following these steps, your UITableView
cells should automatically adjust their size based on their content, providing a flexible and dynamic layout.

Get started with Dynamic Type
Dynamic Type lets people choose their preferred text size across the system and all of their apps. To help you get started supporting Dynamic Type, we’ll cover the fundamentals: How it works, how to find issues with scaling text in your app, and how to take practical steps using SwiftUI and UIKit to create a great Dynamic Type experience. We’ll also show how you can best use the Large Content Viewer to make navigation controls accessible to everyone.

Make your UIKit app more flexible
Find out how your UIKit app can become more flexible on iPhone, iPad, Mac, and Apple Vision Pro by using scenes and container view controllers. Learn to unlock your app’s full potential by transitioning from an app-centric to a scene-based lifecycle, including enhanced window resizing and improved multitasking. Explore enhancements to UISplitViewController, such as interactive column resizing and first-class support for inspector columns. And make your views and controls more adaptive by adopting new layout APIs.

What’s new in UIKit
Explore everything new in UIKit, including tab and document launch experiences, transitions, and text and input changes. We’ll also discuss better-than-ever interoperability between UIKit and SwiftUI animations and gestures, as well as general improvements throughout UIKit.