【问题标题】:How to get 'child controllers' reference of NavigatorIOS in React-native?如何在 React-native 中获取 NavigatorIOS 的“子控制器”参考?
【发布时间】:2016-07-22 06:11:19
【问题描述】:

刚学了几天react-native。现在遇到一个关于NavigatorIOS组件的问题。我想知道是否有可能在 react-native 中获得 NavigatorIOS 的“子控制器”,就像在原生 Objective-c 中一样(使用 UINavigationController.viewControllers)。我想获取参考并调用一些更新方法。

_addNavigator: function (component, title) {

    var data = null;

    var temp = <NavigatorIOS
      style={{ flex: 1 }}
      barTintColor='#007AFF'
      titleTextColor="#fff"
      tintColor="#fff"
      translucent={false}
      initialRoute={{
        component: component,
        title: title,
        passProps: {
          data: data
        }
      }}/>;

    componentArray.push(temp);

    return temp;
  }

【问题讨论】:

    标签: javascript ios navigation react-native


    【解决方案1】:

    在 NavigatorIOS 中无法获取子控制器的引用,但我们可以使用 EventEmitter lib 来满足我们的要求。 EventEmitter 类似于 NSNotification。欲了解更多信息,请查看链接EventEmitter

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-03-25
      • 2013-06-12
      • 2015-08-07
      相关资源
      最近更新 更多