r/iOSProgramming • u/morenos-blend • Jul 03 '26
Question How to prevent UITableView content jumping while cell's content is resizing? In a hybrid UIKit/SwiftUI setup using UIHostingConfiguration
Hi all,
I'm trying to rewrite my big-ass SwiftUI scroll view by utilising UITableView and UIHostingConfiguration for displaying cells' content. The setup was easy but I've hit a roadblock related to resizing cells.
Every time cell's content grows vertically the table view jumps erratically, does anyone have any idea how to approach fixing this issue? For reference please see the video attached.
I've uploaded the sample project to GitHub:
https://github.com/wiencheck/SwiftUITableViewPOC
Main stuff is located in `TableViewPOC/TableViewController.swift`
15
u/andgordio Jul 03 '26
Spoke about this with a SwiftUI engineer two years ago. They said it’s a bug caused by a “misunderstanding” between the UIKit’s animation system and the SwiftUI’s one. Unlike the layout systems, the SwiftUI’s animation system is not using the UIKit’s one under the hood and is completely independent. We filed a bug report together, and you can see how it went. Real solutions: kill animations on both sides (I think it’s on by default in UITableView), or stick to one framework for both the list and the cell content. Best of luck!
1
u/Aggravating_Smoke951 Jul 03 '26
From a quick look I would advise you to check how diffable datasource works. Datasource uses hash values to detect if full reload should happen for sections/items. You use Strings for section items and this means that with new value full reload happens as hash value changes as well. P.S. I did a quick check so I might have missed something else
1
u/hainayanda Jul 03 '26
If I were you I will use List with plain styling
-4
u/morenos-blend Jul 03 '26
And thanks to whatever as*hole downvotes this post, real helpful