如何在stackNavigator屏幕内水平滑动? [英] How to swipe horizontally inside stackNavigator screens?
问题描述
我正在尝试使用同一个 StackNavigator
I'm trying to create a swipe navigation between different screens from a same StackNavigator
当我在 navigationOptions
中设置 swipeEnabled:true
时,我的应用程序会在不同的选项卡之间导航.
when i set swipeEnabled:true
in navigationOptions
, my app rather navigate between different Tabs.
例如,我希望在同一个堆栈中从 Screen A
导航到 Screen B
.
I'd rather want to navigate inside a same stack from Screen A
to Screen B
for example.
我该怎么做?
推荐答案
我有同样的用例.我想要一个可滑动的
.我能找到的解决方案是使用
或更具体地说,使用 createMaterialTopTabNavigator()
模拟
>.
I had the same use case. I wanted a swipaeable <StackNavigator>
. The solution I was able to find was to simulate a <StackNavigator>
using a <TabNavigator>
, or more specifically, using createMaterialTopTabNavigator()
.
我所做的是创建此选项卡(这是 react-navigation 2 中唯一允许 swipeEnabled
的选项卡)并将 display: none
添加到其样式中.这样我就可以有一个
,它的行为就像一个
.
What I did was to create this tab (which is the only in the react-navigation 2 which allows swipeEnabled
) and added display: none
to its style. This way I can have a <TabNavigator>
that behaves like a <StackNavigator>
.
这是代码:
const SwipeableNavigator = createMaterialTopTabNavigator({
FrontCard: FrontCardScreen,
BackCard: BackCardScreen
},
{
swipeEnabled: true,
tabBarOptions: {
style: { display: "none" }
}
});
然后在任何你想要的地方调用
.
And then just call <SwipeableNavigator />
wherever you want.
这篇关于如何在stackNavigator屏幕内水平滑动?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!