惠..
我目前正在玩反应导航并尝试解决当抽屉打开时标题未隐藏的问题...
我希望任何人都可以分享如何解决这个错误的标题..我在StackNavigator中附加了DrawerNavigator的代码集成。
const Home = DrawerNavigator({
HomeMenu: { screen: HomeMenu },
Messages: { screen: Messages },
Notifications: { screen: Notifications },
Badges: { screen: Badges },
Leaderboard: { screen: Leaderboard },
Profile: { screen: Profile },
Logout: { screen: Logout }
});
const MainActivity = StackNavigator({
Home: { screen: Home }
})

提前谢谢!
答案 0 :(得分:3)
您可以隐藏标题,如: -
const Home = DrawerNavigator({
HomeMenu: { screen: HomeMenu,
navigationOptions: {
header:false, //hide header if not needed so whole screen slide
},
},
Messages: { screen: Messages },
Notifications: { screen: Notifications },
Badges: { screen: Badges },
Leaderboard: { screen: Leaderboard },
Profile: { screen: Profile },
Logout: { screen: Logout }
});
const MainActivity = StackNavigator({
Home: { screen: Home }
})
答案 1 :(得分:2)
我有同样的问题(TabNav嵌套在DrawerNav中)并找到了一个我想分享的 super 简单修复!我们在 Validation (ASP.Net): Attribute 'ID' is not a valid attribute of element 'RadTab'.
的回购中讨论了此问题here。我实现的修复程序(在您要隐藏的屏幕上):
react-navigation
},
版本略有不同:
MAIN: {
screen: MainTabs,
navigationOptions: {
drawerLabel: () => null // to hide this header
},
}
希望这有帮助!
答案 2 :(得分:1)
在 DrawerNavigator 中使用 StackNavigator 并将headerMode: 'none'
设置为root StackNavigator
const MenuStackNavigator = StackNavigator({
Dashboard: {
screen: Dashboard,
navigationOptions: {
title: 'Dashboard',
}
},
});
const PagesStackNavigator = StackNavigator({...});
const DrawerNavigator = DrawerNavigator({
MenuStack: {
screen: MenuStackNavigator,
navigationOptions: {
drawer: () => ({
label: 'MenuStackNavigator',
})
},
},
Pages: {
screen: PagesStackNavigator,
navigationOptions: {
drawer: () => ({
label: 'PagesStackNavigator',
})
},
}
});
const AppNavigator = StackNavigator({
Drawer: { screen: DrawerNavigator },
}, {
headerMode: 'none',
});
答案 3 :(得分:0)
我找到了方法,我只需要做相反的事情.. 将DrawerNavigator作为根导航器并将StackNavigator放入其中..然后打开抽屉时将没有标题
答案 4 :(得分:0)
我也在解决这个问题,发现StackNavigator必须嵌套在Drawer中,但是这个解决方案有很多问题,例如同步抽屉和卡片堆栈中的活动菜单状态。
// Manifest of possible screens
const MenuButton = ({ navigation }) => (
<View>
<TouchableOpacity onPress={() => navigation.navigate('DrawerOpen')}>
<Icon name="bars" style={{color: 'white', padding: 10, marginLeft:10, fontSize: 20}}/>
</TouchableOpacity>
</View>
);
const Nav = StackNavigator({
StoriesScreen: {
screen: StoriesScreen,
navigationOptions: { title: 'Stories' }
},
LaunchScreen: { screen: LaunchScreen },
LoginScreen: {
screen: LoginScreen,
navigationOptions: { title: 'Login' }
}
}, {
navigationOptions: {
header: navigation => ({
style: styles.header,
left: <MenuButton navigation={navigation} />,
}),
}
})
const PrimaryNav = DrawerNavigator({
StoriesScreen: {
screen: Nav,
navigationOptions: { title: 'Stories' }
},
LaunchScreen: { screen: LaunchScreen },
LoginScreen: {
screen: LoginScreen,
navigationOptions: { title: 'Login' }
}
})
答案 5 :(得分:0)
我也有同样的问题,并通过在主StackNavigator中添加&#34; headerMode&#34;:none来解决。
示例:
const AppMainStack = DrawerNavigator({
ActivitiesScreen: {screen: ActivitiesScreen},
}, {
drawerPosition: 'right',
});
const AppNavigator = StackNavigator({
StartScreen: {screen: StartScreen},
EnterCodeScreen: {screen: EnterCodeScreen},
CreateAccountScreen: {screen: CreateAccountScreen},
ProfileSetupScreen: {screen: ProfileSetupScreen},
SignInScreen: {screen: AppMainStack},
}, {
headerMode: 'none',
});