React本机和现有应用程序IOS之间的通信

时间:2016-08-04 09:39:09

标签: ios swift react-native

我对Swift很新,并且反应原生。 我正在尝试在现有的IOS应用程序中集成react native并且文档在某一点上不是很清楚:假设我从appDelegate启动了一个带有React Native的应用程序(就像那样)?

let rootView: RCTRootView = RCTRootView(bundleURL: jsCodeLocation, moduleName: "MainScreen", initialProperties: nil, launchOptions: launchOptions)
    self.window = UIWindow(frame: UIScreen.mainScreen().bounds)
    let rootViewController: UIViewController = UIViewController()
    rootViewController.view = rootView

    self.window!.rootViewController = rootViewController
    self.rootViewController = rootViewController
    self.window!.makeKeyAndVisible()

工作得很好,我可以看到我的React Native应用程序,但是当我想要去原生部分,到原生屏幕时,如何使这个segue工作还不是很清楚。我做了一个本机模块类,我可以从本机访问但我不明白如何从那里调用本机View控制器或我应该关闭反应rootController或什么?

我试过像

那样的人

让vc = FirstViewController()//目标控制器     delegate.rootViewController!.presentViewController(vc,animated:true,completion:nil)

这个以某种方式不会初始化按钮和东西,并给了我很多的nils 所以我的问题是如何从反应到本地和后退? 任何提示都会非常有用!

0 个答案:

没有答案