Static table view outside UITableViewController
Data Structures & Algorithms practice on Codemia
Step through 300+ coding interview problems with animated visualisers that show the data structure changing as the code runs. The Blind 75 are free.
Introduction
In Interface Builder, true storyboard-backed static table view cells are supported only inside a UITableViewController. If you place a UITableView inside a plain UIViewController, you cannot use the built-in "Static Cells" mode the same way. That is the key limitation behind this question.
What "Static Cells" Really Means
When Apple says a table view uses static cells, it means the cell structure is defined in the storyboard and managed by a UITableViewController. The controller is part of the feature, not just a convenient wrapper.
So this is the important rule:
- '
UITableViewControllersupports storyboard static cells' - '
UIViewControllerwith an embeddedUITableViewdoes not'
That is why changing the controller class but keeping the same storyboard expectation does not work.
Option 1: Use a Child UITableViewController
If you need other UI around the table but still want storyboard static cells, embed a UITableViewController as a child view controller.
That lets you keep:
- static cell support
- table-specific lifecycle behavior
- surrounding custom UI in the parent controller
Conceptually:
This is the closest equivalent to "static table view outside UITableViewController" while still using the built-in static-cell feature.
Option 2: Use a Normal Dynamic Table With Fixed Data
Very often, the practical answer is to stop depending on static-cell mode and instead use a normal table view with a fixed data model:
This is "dynamic" from UIKit's perspective, but if your array is fixed, it behaves like a static settings screen with far more flexibility.
Option 3: Use a Stack View for Form-Like Screens
If the content is truly fixed and not naturally tabular, a UIStackView plus custom views may be better than forcing everything into a table.
That is often cleaner for:
- profile forms
- settings screens with custom spacing
- mixed layouts that are not really row-based
Developers sometimes reach for static table cells when the UI is not actually a table problem at all.
Why UITableViewController Is Special
UITableViewController automatically manages things such as:
- table view ownership
- selection behavior
- content insets and scrolling defaults
- storyboard static-cell integration
When you leave that controller type, you gain layout freedom, but you lose the special-case static-cell support.
Common Pitfalls
The biggest mistake is expecting the "Static Cells" storyboard option to behave the same inside a plain UIViewController. It does not.
Another mistake is forcing a fixed settings layout into a full table view when a stack view or child controller would be simpler.
A third issue is recreating static behavior manually while still assuming UITableViewController conveniences are present.
Summary
- Storyboard static table view cells are supported only with
UITableViewController. - A plain
UIViewControllerwith aUITableViewdoes not get that built-in static-cell mode. - Use a child
UITableViewControllerif you want static cells plus surrounding custom UI. - Otherwise, use a normal table view with a fixed data source or switch to a stack-based layout.
- The right solution depends on whether the screen is truly a table or just a fixed form-like view.
Related reading
- Static vs class functions/variables in Swift classes?
- Static way to get 'Context' in Android?
- Static way to get 'Context' in Android?
- Status bar and navigation bar appear over my view's bounds in iOS 7
- Status bar height in Swift
- Status bar height in Swift
- Still getting warning Configuration 'compile' is obsolete and has been replaced with 'implementation
- Stop UIWebView from bouncing vertically?
.png&w=3840&q=75)
Tackling System Design Interview Problems
A short course that equips you with the skills to approach system design interviews methodically.
Start the free courseNo course covers this one yet
Basis Lab writes one for you from a sentence about what you want to be able to do, then teaches it and checks you understood. Your first course is free.
Build my courseData Structures & Algorithms practice on Codemia
Step through 300+ coding interview problems with animated visualisers that show the data structure changing as the code runs. The Blind 75 are free.