如何在 React Native 中显示隐藏的导航栏
我在 React Native 中使用 NavigatorIOS 很麻烦,
i am troubling using of NavigatorIOS in react native,
<NavigatorIOS
style={styles.navigator}
initialRoute={{
title:'xxx',
component:xxx
}}
navigationBarHidden={true} />
这里的组件 xxx 是我的起始文件,我不需要导航器,在此之后我使用登录屏幕,在完成这些屏幕后我也不需要导航器,我需要在我的屏幕中使用导航器.为了隐藏我使用上面的代码但在子屏幕中显示它我是这样写的但没有显示
here component xxx is my starting file here i don’t want navigator,after this i am using login screen there also i don’t want navigator after completion of the these screens,I need a navigator in my screen. for hiding i used above code but to show it in child screen i wrote like this but not showing
this.props.navigator.push({
component:xxxx
title:’xxxx’,
navigationBarHidden:false
})
非常感谢任何帮助
使用 NavigatorIos 时有很多问题.您有 2 个选择:
There are a lot of issues when using NavigatorIos. You have 2 options:
转储 NavigatorIos 并移至 Navigator.我跟你情况一样.我正在使用 NavigatorIos,我想完全替换场景.这是一个已知问题,由于 Facebook 停止开发它并完全转移到 Navigator,我几乎被迫做出改变.以下是更多信息:导航器比较
您可以使用像这样的自定义导航器 Kureev 的一个.但是,您应该考虑到他实现它的方式,导航栏是您视图的一部分,因此当您移动到一个新场景时,整个页面都会移动,包括您的导航栏.
You can use a custom navigator like this one by Kureev. However, you should take into consideration that the way he implemented it, the navigator bar is part of your view, so when you move to a new scene, the whole page shifts, including your navigator.
我尝试了选项 #1 和 #2,最终选择了 #1,并且再也没有回头.它感觉更原生,并且越来越多的人支持它.
I tried both option #1 and #2, and ultimately went with #1 and never looked back. It feels much more native and there is growing support for it.
希望有所帮助.