将React Native Navigation与RCTRootView一起使用

时间:2018-08-08 14:39:23

标签: react-native react-native-navigation

我正在努力将一些React Native屏幕添加到现有的iOS应用中。我遵循了Integration with Existing Apps上概述的步骤,并且能够在我的XCode项目中使用以下代码查看我的React Native屏幕:

"."

我正在这样注册我的根组件:

    NSURL *jsCodeLocation = [NSURL URLWithString:@"http://localhost:8081/index.bundle?platform=ios"];

    RCTRootView *rootView =
    [[RCTRootView alloc] initWithBundleURL: jsCodeLocation
                                moduleName: @"RNTestView"
                         initialProperties:@{}
                             launchOptions: nil];

    [self.view addSubview:rootView];

,并且在我的Navigation.registerComponent('RNTestView', () => RNTestView); 组件中包含以下内容:

RNTestView

当我运行该应用并展示我的class RNTestView extends Component { static get options() { return { topBar: { title: { text: 'My Screen' }, drawBehind: true, visible: true, animate: false } }; } render() { return ( <View> <Text>Test</Text> </View> ); } } export default RNTestView; 时,我可以看到我的RCTRootView组件,但是没有导航栏。

如何将RNN成功添加到我的项目中,并在视图顶部显示可导航栏?

0 个答案:

没有答案
相关问题