本机:如何使用嵌套在基于本机的Tab组件内的水平滚动视图?

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

我正在使用基于本机的Tabs,我想在其中一个选项卡中使用水平ScrollView

我的代码如下:

<Tabs>
      <Tab
          <MyComponent/>
      </Tab>
      <Tab
          <MyComponent/>
      </Tab>
</Tabs>

但是孩子的卷轴不起作用。

react-native scrollview horizontalscrollview native-base
1个回答
0
投票

当孩子滚动时,我设法使其锁定了父选项卡。

有显示如何做的小吃here

这里是相关代码:

<Tabs locked={this.state.isLocked}>
     <Tab
         <MyComponent lockTab={this.lockTab}/>
     </Tab>
     <Tab
         <MyComponent/>
     </Tab>
</Tabs>

MyComponent内部:

  handleInnerPressIn = () => this.props.lockTab(true);
  handleInnerPressOut = () => this.props.lockTab(false);

  <TouchableWithoutFeedback
              onPressIn={this.handleInnerPressIn}
              onPressOut={this.handleInnerPressOut}>
      <ScrollView nestedScrollEnable={true} horizontal={true}>
      </SrollView>
  </TouchableWithoutFeedback>
© www.soinside.com 2019 - 2024. All rights reserved.