Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save BrianChevalier/69e5fb5b04637187dc914131514d16dd to your computer and use it in GitHub Desktop.
Save BrianChevalier/69e5fb5b04637187dc914131514d16dd to your computer and use it in GitHub Desktop.
  • Instantiate UIHosting Controller
  • pass a reference to self which is of type UIDocumentBrowserViewController
//This is somewhere in the present method of my UIDBVC subclass
let documentViewController = UIHostingController(rootView: SomeView(rootVC: self))

* In the UIDBVC subclass I created this method
```swift
func dismissVC() {
  dismiss(animated: true, completion: nil)
}
  • The SwiftUI View calls the dismissVC method of the UIDBVC subclass
struct SomeView: View {

  var rootVC: myDocumentBrowserViewControllerSubclass
  
  var body: some View{
    Button(
      action: { self.rootVC.dismissVC() },
      label: { Text("Dismiss this View") }
    )
  }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment