title: SwiftUI go to another view from UIViewController
body: <p>I have a project which built with SwiftUI and to be able to use stripe I am now integrating UIKit into this SwiftUI project. This is an example of what I want to do. I want to go to another view from UIKit.
  Here is my content view in SwiftUI. If you copy paste this code it will work on your xcode also.</p>
  <pre><code>import SwiftUI
  import UIKit
  
  struct ContentView: View {
      var body: some View {
          ViewControllerWrapper(controller: MyViewController.init())
      }
  }
  
  struct ContentView_Previews: PreviewProvider {
      static var previews: some View {
          ContentView()
      }
  }
  
  class MyViewController: UIViewController{
      lazy var goToAnotherViewButton: UIButton = {
          let button = UIButton(type: .custom)
          button.layer.cornerRadius = 5
          button.backgroundColor = .systemYellow
          button.titleLabel?.font = UIFont.systemFont(ofSize: 22)
          button.setTitle(&quot;Go&quot;, for: .normal)
          button.addTarget(self, action: #selector(goToAnotherView), for: .touchUpInside)
          return button
      }()
      override func viewDidLoad() {
          super.viewDidLoad()
          view.backgroundColor = .white
          let stackView = UIStackView(arrangedSubviews: [goToAnotherViewButton])
          stackView.axis = .vertical
          stackView.spacing = 20
          stackView.translatesAutoresizingMaskIntoConstraints = false
          view.addSubview(stackView)
          NSLayoutConstraint.activate([
              stackView.leftAnchor.constraint(equalToSystemSpacingAfter: view.leftAnchor, multiplier: 2),
              view.rightAnchor.constraint(equalToSystemSpacingAfter: stackView.rightAnchor, multiplier: 2),
              stackView.topAnchor.constraint(equalToSystemSpacingBelow: view.topAnchor, multiplier: 2),
          ])
      }
      
      @objc
      func goToAnotherView() {
              //from this function I want to go to Another View
          }
  }
  
  struct ViewControllerWrapper: UIViewControllerRepresentable{
      func makeUIViewController(context: UIViewControllerRepresentableContext&lt;ViewControllerWrapper&gt;) -&gt; UIViewController {
          guard let controller=controller else {
              return UIViewController()
          }
          return controller
      }
      func updateUIViewController(_ uiViewController: UIViewController, context: UIViewControllerRepresentableContext&lt;ViewControllerWrapper&gt;) {
      }
      let controller:UIViewController?
      typealias UIViewControllerType = UIViewController
  }
  </code></pre>