DevPrep

All topics › SwiftUI

How does SwiftUI integrate with UIKit?

Middle PRO

Two directions

UIKit inside SwiftUI — UIViewRepresentable / UIViewControllerRepresentable:

SwiftUI inside UIKit — UIHostingController(rootView:) as a regular controller (child VC, push, modal) and UIHostingConfiguration (iOS 16) for the contents of UITableView/UICollectionView cells. sizingOptions = [.intrinsicContentSize] lets the hosting controller update its size when the content changes.

The rest of this answer, with code and interview follow-ups, is in the DevPrep app.

Read the full answer in DevPrep

Practice this before your interview

DevPrep turns these answers into one-minute challenges: what does this code print, find the bug, mock interviews. One challenge a day.

Get DevPrep on the App Store