Skip to content

Instantly share code, notes, and snippets.

@duytq94
Last active April 14, 2020 07:10
Show Gist options
  • Save duytq94/821e278dc238f50c94dfdb725021694e to your computer and use it in GitHub Desktop.
Save duytq94/821e278dc238f50c94dfdb725021694e to your computer and use it in GitHub Desktop.
class ViewController: UIViewController {
@IBOutlet weak var textField: UITextField!
@IBAction func BtnGoReactView(_ sender: Any) {
let messageFromNative: String = textField.text!
let rootView = RNViewManager.sharedInstance.viewForModule(
"DemoIntegrateRN",
initialProperties: ["message_from_native": messageFromNative])
let reactNativeVC = UIViewController()
reactNativeVC.view = rootView
reactNativeVC.modalPresentationStyle = .fullScreen
present(reactNativeVC, animated: true)
}
override func viewDidLoad() {
super.viewDidLoad()
self.hideKeyboardWhenTappedAround()
}
func hideKeyboardWhenTappedAround() {
let tap = UITapGestureRecognizer(target: self.view, action: #selector(UIView.endEditing))
tap.cancelsTouchesInView = false
view.addGestureRecognizer(tap)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment