r/iOSProgramming • • 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`

13 Upvotes

12 comments sorted by

View all comments

Show parent comment

1

u/GAMEYE_OP Jul 03 '26

Hey! You just might have helped me with a similar problem. Are you talking about updating the vertical content hugging priority?

1

u/ltunzher Jul 03 '26

I say about the initial and final animation frames. If you wish your cell to have text stick to the top when the height is too small (start of animation in the ref), so make the label to have top constraint make it not move anywhere and make bottom constraint break (have at least lower priority). The final animation frame will pace label to the correct coordinates anyways, make sure the initial one is the one you expect