简体   繁体   English

导航抽屉未在react-native中呈现

[英]Navigation drawer not getting rendered in react-native

Hey guys i am new to react-native and trying to build navigation drawer with hamburger icon on navigation bar. 大家好,我是新来的本机人员,正在尝试使用导航栏上的汉堡包图标构建导航抽屉。 I can see the navigation bar but failed to render hamburger icon . 我可以看到导航栏,但无法渲染汉堡包图标。 Also the code is not getting rendered when i try to integrate it with other screen Here is my code for toolbar.js 当我尝试将其与其他屏幕集成时,代码也不会呈现。这是我的toolbar.js代码

class toolbar extends Component {
  render(){
    var navigator = this.props.navigator;
    return (
    <ToolbarAndroid
     title={this.props.title}
     navIcon={require('./img/menu.png')}
     style = {styles.toolbar}
     titleColor={'white'}
     onIconClicked={this.props.sidebarRef}/>
    );
  }
}

And OpenDrawerFromToolbar.js code 和OpenDrawerFromToolbar.js代码

var navigationView = (
    <ScrollView>
      <View style={{flex: 1, backgroundColor: '#fff'}}>
      <Text style={{margin: 10, fontSize: 15, textAlign: 'left'}}>I m in the Drawer!</Text>
      </View>

    </ScrollView>
);

return (
  <DrawerLayoutAndroid
    drawerWidth={windowsWidth/1.5}
    drawerPosition={DrawerLayoutAndroid.positions.Left}
    renderNavigationView={() => navigationView}
    ref={'DRAWER'}>
    <Toolbar style={styles.toolbar}
        title={'Calendar'}
        navigator={this.props.navigator}
        sidebarRef={()=>this._setDrawer()}/>
    <View style={{alignItems: 'center', backgroundColor: 'blue'}}>
      <Text style={{margin: 10, fontSize: 15, textAlign: 'right'}}>Hi MiaMia</Text>
    </View>
  </DrawerLayoutAndroid>
);
}

 _setDrawer() {
   this.refs['DRAWER'].openDrawer();
  }
 }

when running OpenDrawerFromToolbar.js solely it runs without rendering the hamburger icon. 仅在运行OpenDrawerFromToolbar.js时,它会在不渲染汉堡包图标的情况下运行。 when i try to integrate with some other views it fails to get rendered. 当我尝试与其他一些视图集成时,它无法呈现。 can anybody guide me through this? 有人可以指导我吗? 图标不显示 我只是得到图标标题的另一个例子

Thanks alot in advance. 在此先感谢。 Any queries or doubts are welcome. 任何疑问或疑问都欢迎。

Can you send me your project file structure snapshot with your image/icons folder.. ... 您可以将您的项目文件结构快照和您的image / icons文件夹发送给我吗?

I don't think you can implement toolbar style like this : 我认为您无法实现这样的工具栏样式:

<Toolbar style={styles.toolbar} //here is the error 
 title={'Calendar'} 
 navigator={this.props.navigator} 
 sidebarRef={()=>this._setDrawer()}/>

And send me your toolbar style stylesheet too.. 并将您的工具栏样式样式表也发送给我。

Its better to implement toolbar style in toolbar.js file .. but still let me have a look at your style first .. 最好在toolbar.js文件中实现工具栏样式..但仍然让我先看看您的样式..

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM