ios - React Native 版本 0.13.1 TabBar 图标不显示

标签 ios icons react-native tabbar

似乎原生 tabBar 图标没有显示,包也没有与应用程序集成。我不确定问题出在哪里,这是我的代码:

'use strict';

var React = require('react-native');
var Featured = require('./App/Components/Featured');
var Search = require('./App/Components/Search');

var {
    AppRegistry,
    TabBarIOS,
    Component
   } = React;

class BookSearch extends Component {

    constructor(props) {
        super(props);
        this.state = {
            selectedTab: 'featured'
        };
    }

    render() {
        return (
            <TabBarIOS selectedTab={this.state.selectedTab}>
                <TabBarIOS.Item
                    selected={this.state.selectedTab === 'featured'}
                    icon={{uri:'featured'}}
                    onPress={() => {
                        this.setState({
                            selectedTab: 'featured'
                        });
                    }}>
                    <Featured/>
                </TabBarIOS.Item>
                <TabBarIOS.Item
                    selected={this.state.selectedTab === 'search'}
                    icon={{uri:'search'}}
                    onPress={() => {
                        this.setState({
                            selectedTab: 'search'
                        });
                    }}>
                    <Search/>
                </TabBarIOS.Item>
            </TabBarIOS>
        );
    }
}

AppRegistry.registerComponent('BookSearch', () => BookSearch);

但这是模拟器:

enter image description here

模拟器正确地更改了选项卡,但选项卡图标根本不显示。如果可能的话,我很乐意提供任何帮助!

最佳答案

我遇到了类似的问题。您是否将 RCTImage 子规范添加到您的 podfile 中?

参见:https://facebook.github.io/react-native/docs/embedded-app-ios.html#install-react-native-using-cocoapods

# Depending on how your project is organized, your node_modules directory may be
# somewhere else; tell CocoaPods where you've installed react-native from npm
pod 'React', :path => '../node_modules/react-native', :subspecs => [
  'Core',
  'RCTImage',
  'RCTNetwork',
  'RCTText',
  'RCTWebSocket',
  # Add any other subspecs you want to use in your project
]

关于ios - React Native 版本 0.13.1 TabBar 图标不显示,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33315021/

相关文章:

ios - 使用 UISwitch 更改初始 ViewController

ios - 如何创建一个允许对 UIImageViews 进行分页和缩放的 UIScrollView?

objective-c - 应用程序不再在设备上运行......吓坏了

ios - SPTAudioStreamingController 停止 playURIs 短缓冲区

reactjs - 如何使用它的snake_case名称动态加载图标(React,material-ui)

html - 使用 Rails、带有精美扩展的 spree 进行部署时图标会中断

css - Webkit 或 css3 中的图标集

react-native - 热重载应该如何在 native react 中工作?

reactjs - 选择器无法接受 borderRadius 表单样式

reactjs - 如何使用 React Hooks 在第一次渲染时加载带有 props 的子组件