Skip to content

Instantly share code, notes, and snippets.

@lucsoft
Created April 26, 2020 20:34
Show Gist options
  • Save lucsoft/0ddf1f06f84db12c9636b50282ce4256 to your computer and use it in GitHub Desktop.
Save lucsoft/0ddf1f06f84db12c9636b50282ce4256 to your computer and use it in GitHub Desktop.
import UIKit
import Social
import SwiftUI
import MobileCoreServices
@objc(CustomShareNavigationController)
class CustomShareNavigationController: UINavigationController {
override init(nibName nibNameOrNil: String?, bundle nibBundleOrNil: Bundle?) {
super.init(nibName: nibNameOrNil, bundle: nibBundleOrNil)
self.loadView()
// 2: set the ViewControllers
print(self.extensionContext);
self.addChild(UIHostingController(rootView: CustomShareViewController(context: self.extensionContext)))
}
@available(*, unavailable)
required init?(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)
}
}
struct CustomShareViewController: View {
var context: NSExtensionContext?;
var body: some View {
Button(action: {print(self.context)}) {
Text(String(describing: context))
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment