NavigatorIOS中的TabBarIOS [React Native]

时间:2016-08-05 16:36:26

标签: react-native

是否无法在NavigatorIOS组件中显示TabBarIOS组件?

例如:

navigator.js

return(
 <NavigatorIOS ref="nav"style={styles.wrapper} initialRoute={{ component: Detail, title: '…', rightButtonTitle: I18n.t('Registrieren'), props: {navigator: this}, backButtonTitle: I18n.t('Zurück')}}/>
)

detail.js

return(
    <TabBarIOS>…</TabBarIOS>
)

1 个答案:

答案 0 :(得分:0)

是的,这是可能的。

import React, { Component } from "react";
import {View, Text, TabBarIOS, NavigatorIOS} from "react-native";`

class Second extends Component {
    constructor(props) {
        super(props);
        this.state = {
          selectedTab: "myTab"
        };
  };

  render(){
    return (
      <TabBarIOS selectedTab={this.state.selectedTab}>

       <TabBarIOS.Item
         selected={this.state.selectedTab === "myTab"}
         icon={require("myTab.png")}
         title="My Tab"
             onPress={() => {
               this.setState({
               selectedTab: "myTab",
           });
         }}>
        <View>
         <Text>My Tab</Text>
        </View>
     </TabBarIOS.Item>
    </TabBarIOS>
    )
  }
}

export default class App extends Component<{}> {
  render(){
    return(
        <NavigatorIOS
            initialRoute={{
                navigationBarHidden: true,
              component: Second
            }}
        />);
  };
}