首页 > 解决方案 > 如何使用wix反应本机导航隐藏ios上的后退按钮

问题描述

我整个早上都被这个问题困住了。我已经阅读了多个 GitHub 问题和 StackOverflow 帖子,但没有任何效果。

我想删除下图左上角的蓝色后退按钮。 在此处输入图像描述 我注意到我无法完全自定义顶部栏。我无法为后退按钮等添加标题(此提示可能表明出了什么问题)。

导航.setRoot

Navigation.events().registerAppLaunchedListener(() => {
  Reactotron.log('5');
  Navigation.setRoot({
    root: {
      stack: {
        children: [{
          component: {
            id: STARTING_SCREEN,
            name: STARTING_SCREEN
          }
        }],
      }
    },
    layout: {
      orientation: 'portrait',
    },
  }).then(()=>Reactotron.log('7'));

导航.push

SplashScreen(根屏幕)-> AccessScreen(下一个屏幕)。

Navigation.push(this.props.componentId, {
  component: {
    name: screen
  },
  options: {
    topBar: {
      backButton: {
        visible: false,
      }
    }
  }

就好像我在错误的地方指定了 backButton 选项。

标签: react-nativereact-native-iosreact-native-navigationwix-react-native-navigation

解决方案


使用它,但仅适用于 ios

Navigation.setDefaultOptions({
    topBar: {
      backButton: {
        visible: false
      }
    },
})

或者你可以自定义 topBar

Navigation.push(this.props.componentId, {
  component: {
    name: screen
  },
  options: {
    topBar: {
      backButton: {
        background: YourComponent
      }
    }
  }

推荐阅读