2

I am working on my SwiftUI Project and every View is now in SwiftUI, however due to some limitations of SwiftUI I have to add Storyboard's ViewControllers into my SwiftUI project. I am trying this method.

struct HomePageView: UIViewControllerRepresentable {
    
    public typealias UIViewControllerType = HomeViewController
    var producttapped:(SelectedProduct)->()
    var bannerTapped:((String)->())
    var CategoryTapped:((Int,Int)->())
    var saveBigTapped:((SaveBigModel, HomeResponseModel)->())
    

    func makeUIViewController(context: UIViewControllerRepresentableContext<HomePageView>) -> HomeViewController {
        let storyboard = UIStoryboard(name: "Storyboard", bundle: nil)
        let plpVC = storyboard.instantiateViewController(identifier: "HomeViewController") as! HomeViewController
        plpVC.producttapped = producttapped
        plpVC.CategoryTapped = CategoryTapped
        plpVC.saveBigTapped = saveBigTapped
        plpVC.bannerTapped = self.bannerTapped
  
        return plpVC
    }
    func updateUIViewController(_ uiViewController: HomeViewController, context: UIViewControllerRepresentableContext<HomePageView>) {
    }
}

but when the home page load ViewDidLoad() called multiple times? How to solve this

Ben10
  • 3,221
  • 2
  • 34
  • 61

0 Answers0