当应用处于横向模式时禁用抽屉

时间:2018-01-16 13:11:30

标签: ios react-native react-navigation

我正在研究一种功能,我希望在应用处于横向模式时禁用抽屉,适用于iOS和& Android系统。我在React-Navigation中看到了DrawerView。

render() {
 // some code
    return (
      <DrawerLayout
        ref={(c: *) => {
          this._drawer = c;
        }}
        drawerLockMode={
          (this.props.screenProps && this.props.screenProps.drawerLockMode) ||
          (config && config.drawerLockMode)
        }
      //some code
       >
        <DrawerScreen
          screenProps={this.props.screenProps}
          navigation={this._screenNavigationProp}
        />
      </DrawerLayout>
    );
}

这里screenProps用于处理锁定模式。我可以使用navigationOptions禁用抽屉,但我想在用户更改方向时禁用。 还有一件事我在DrawerNavigator中使用了StackNavigator。

1 个答案:

答案 0 :(得分:0)

首先检查模式How check status of Phone is Landscape or Portrait when Ativity not auto rotation?

的答案

然后相应地做myHandler = () => { let obj = {} obj = this.toggleSaveButton(obj, true); obj = this.toggleLabel(obj, false); obj = this.toggleConfirmationMessage(obj, true); this.setState(obj); } toggleSaveButton= (obj, enabled) => { obj.canSave = enabled; return obj; } toggleLabel= (visible) => { obj.isLabelVisible = visible; return obj; } toggleConfirmationMessage= (visible) => { obj.isConfirmationMessageVisible = visible; return obj; }