-
-
Save laevandus/e12f4bbec3e1caa0e39cfdbe9d9d5571 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Presenting the detail view using UIKit presentation methods | |
let hostingController = DetailView().embeddedInHostingController() | |
presentingViewController.present(hostingController, animated: true) | |
// The view which needs access to the view controller hosting it | |
struct DetailView: View { | |
@EnvironmentObject var hostingProvider: ViewControllerProvider | |
var body: some View { | |
VStack { | |
Text("Detail") | |
Button("Access View Controller") { | |
let viewController = hostingProvider.viewController | |
// … do something with the view controller | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment