Tuesday, October 01, 2024

What is UIViewControllerRepresentable ?

 UIViewControllerRepresentable

Instance to create and manage UIViewController object in our SwiftUI interface

Create UIViewControllerRepresentable 

  • func makeUIViewController(context: Context) -> UIViewController 

Update UIViewControllerRepresentable 

  • func updateUIViewController(_ uiViewController: UIViewController, context: Context){

Specifying Size

  • func sizeThatFits(_: ProposedViewSize, uiViewController: Self.UIViewControllerType, context: Self.Context) -> CGSize?


To provide a custom Co-ordinator Object


  • func makeCoordinator() -> Self.Coordinator


Similarly, we have UIViewRepresentable to manage UIViews.



No comments:

Create a list in SwiftUI with sticky section headers

 Sample Code import SwiftUI struct ContentView : View {     @State var isCustomViewControllerDisplayed = false     @State private va...