当我在设置屏幕上时,我看到缺少评论图标(收藏夹)。它显示我何时回到Review屏幕。为什么会这样。看我拍的截图。从我的项目中粘贴相关的代码片段以供参考。
const MainNavigator = TabNavigator({
map: { screen: MapScreen },
deck: { screen: DeckScreen },
review: {
screen: StackNavigator({
review: { screen: ReviewScreen },
settings: { screen: SettingsScreen }
})
}
}, {
tabBarPosition: 'bottom',
tabBarOptions: {
labelStyle: { fontSize: 12 }
}
});
class ReviewScreen extends Component {
static navigationOptions = props => {
const {navigation} = props;
const {navigate} = navigation;
return {
tabBarIcon: ({ tintColor }) => {
return <Icon name="favorite" size={30} color={tintColor} />
},
headerTitle: 'Review Jobs',
headerRight: (
<Button
title="Settings"
onPress={() => navigate('settings')}
backgroundColor="rgba(0,0,0,0)"
color="rgba(0, 122, 255, 1)"
/>
)
}
}
这里的潜在客户表示赞赏。
答案 0 :(得分:2)
您的代码存在问题,因为您要将tintColor
中的每个图标static navigationOptions
设置为
tabBarIcon: ({tintColor}) => {
return <Icon name="favorite" size={30} color={tintColor}/>
}
并且Settings Screen
没有,Icon
也需要TabNavigator
,因为它在null
内,因此navigationOptions
正在那里呈现。
因此,您需要将Settings Screen
中的static navigationOptions = props => {
const {navigation} = props;
const {navigate} = navigation;
return {
tabBarIcon: ({tintColor}) => {
return <Icon name="favorite" size={30} color={tintColor}/>
}
}
}
设置为
App.js
或者您可以将screen: TabNavigator({
map: { screen: MapScreen,
navigationOptions: {
tabBarIcon: ({ tintColor }) => (
<Icon name="favorite" size={30} color={tintColor}/>
)
}
},
// ....so on
导航文件中的默认图标添加为
uBit.init();
uBit.serial.baud(115200);
MicroBitI2C i2c = MicroBitI2C(I2C_SDA0, I2C_SCL0);
MicroBitAccelerometer accelerometer = MicroBitAccelerometer(i2c);
while(1) {
int x=uBit.accelerometer.getX();
int y=uBit.accelerometer.getX();
int z=uBit.accelerometer.getX();
stringstream result;
result << x << "," << y << "," << z;
uBit.serial.send(result.c_str());
uBit.serial.send("\r\n");
}
希望有所帮助!