我正在努力为现有的iOS应用添加一些React Native屏幕 . 我按照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];

我正在注册我的root组件,如下所示:

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 时,我可以看到我的 Text 组件但是没有导航栏 .

如何成功将RNN添加到我的项目中并在我的视图顶部有一个工作导航栏?