我正在使用react-native-tab-navigator:
https://github.com/happypancake/react-native-tab-navigator
<TabNavigator style={styles.container}>
<TabNavigator.Item
selected={this.state.selectedTab === 'home'}
title="Home"
selectedTitleStyle={{color: "#3496f0"}}
renderIcon={() => <Icon name="home" size={px2dp(22)} color="#666"/>}
renderSelectedIcon={() => <Icon name="home" size={px2dp(22)} color="#3496f0"/>}
onPress={() => this.setState({selectedTab: 'home'})}>
<SideMenu menu={MenuComponent}>
<HomeScreen/>
</SideMenu>
</TabNavigator.Item>
<TabNavigator.Item
selected={this.state.selectedTab === 'links'}
title="Links"
selectedTitleStyle={{color: "#3496f0"}}
renderIcon={() => <Icon name="user" size={px2dp(22)} color="#666"/>}
renderSelectedIcon={() => <Icon name="user" size={px2dp(22)} color="#3496f0"/>}
onPress={() => this.setState({selectedTab: 'links'})}>
<SideMenu menu={MenuComponent}>
<LinksScreen/>
</SideMenu>
</TabNavigator.Item>
</TabNavigator>
我的屏幕配置如下:
// app/index.js
import React, { Component } from 'react';
import { Router, Scene } from 'react-native-router-flux';
import HomeScreen from './containers/HomeScreen';
import LinksScreen from './containers/LinksScreen';
import TabNavScreen from './containers/TabNavScreen';
const MyApp = () => {
return (
<Router>
<Scene key="root">
<Scene key="home"
component={HomeScreen}
title="Home"
/>
<Scene
key="links"
component={LinksScreen}
title="Links"
/>
<Scene key="tabNav"
component={TabNavScreen}
title="Home"
initial
/>
</Scene>
</Router>
);
}
export default MyApp;
我需要在更改标签时更改主屏幕的标题。现在它被固定在家里,我尝试的任何东西似乎都不成功。
提前感谢您的帮助。
答案 0 :(得分:0)
如果您将标题作为道具传递,则只需将title={this.props.title}
更改为% Generate sample data...
data = randi([0 99],2,randi([5 10],1));
event = 12;
% Call fopen with permission A (opens or creates a file for writing, appending data)...
fid = fopen('phase.dat','a');
% Write the event header...
fprintf(fid,'Event #%d %s\n',event,datestr(now(),'mmm dd yyyy'));
% Write the event data...
for k = 1:size(data,2)
fprintf(fid,'file #%d %02d %02d\n',k,data(1,k),data(2,k));
end
% Close the file handler...
fclose(fid);