在React Native iOS中是否可以有条件地禁用滑动以返回手势?

问题描述 投票:0回答:1

我正在寻找一种方法来在本机iOS中有条件地禁用滑动以返回手势。我正在使用react-navigation库来控制导航。对于Android,我可以使用BackHandler做到这一点。在iOS中可以做类似的事情吗?

  componentDidMount() {
      BackHandler.addEventListener("hardwareBackPress", this.handleBackButton);
  }

  handleBackButton = () => {
    if (this.props.creating) {
      return true; // Disables the back button in Android
    }
  };

  componentWillUnmount() {
      BackHandler.removeEventListener(
        "hardwareBackPress",
        this.handleBackButton
      );
  }
ios react-native react-navigation
1个回答
0
投票

是,有一个禁用手势的选项:

screen: ExampleView
    navigationOptions: {
        gesturesEnabled: false,
    },

在此处查看更多详细信息:https://github.com/react-navigation/react-navigation/issues/1063

© www.soinside.com 2019 - 2024. All rights reserved.