【问题标题】:IOS failing to render @expo/vector-iconsIOS 无法呈现 @expo/vector-icons
【发布时间】:2021-03-09 13:20:13
【问题描述】:

我们正在使用 expo 的裸工作流项目在我们的应用程序中实现图标。

Expo 文档说不需要在 ios 设备中进行更多配置,但是当我在 ios 中安装 expo install @expo/vector-icons 时,它无法正常工作。图标未呈现。只呈现一个“?”。

在托管工作流程中,它运行良好。但我需要简单的工作流程。

我没有错误信息。只是图标没有出现。

在 xcode 中,我尝试将字体文件夹复制到 xcode 项目并运行 pod install 并链接 react-native 依赖项。但没有成功。

有人遇到过这个问题吗?解决方案是什么?谢谢!

// Example to Use React Native Vector Icons
// https://aboutreact.com/react-native-vector-icons/

// Import React
import React from 'react';

// Import required component
import {SafeAreaView, StyleSheet, Text, View} from 'react-native';

// Import vector icons
import Icon from 'react-native-vector-icons/FontAwesome';

const App = () => {
  return (
    <SafeAreaView style={{flex: 1}}>
      <View style={{flex: 1, padding: 16}}>
        <View style={styles.container}>
          <Text style={styles.heading}>
            Example to Use React Native Vector Icons
          </Text>
          <View style={styles.iconContainer}>
            <Text>
              <Icon name="rocket" size={30} color="#900" />
            </Text>
            {/* Icon Component */}
            <Icon name="rocket" size={30} color="#900" />
          </View>
          <View style={{marginTop: 16, marginBottom: 16}}>
            {/* Icon.Button Component */}
            <Icon.Button
              name="facebook"
              backgroundColor="#3b5998"
              onPress={() => alert('Login with Facebook')}>
              Login with Facebook
            </Icon.Button>
          </View>
        </View>
        <Text style={styles.footerTitle}>Vector Icons</Text>
        <Text style={styles.footerText}>www.aboutreact.com</Text>
      </View>
    </SafeAreaView>
  );
};
const styles = StyleSheet.create({
  container: {
    flex: 1,
    alignItems: 'center',
    justifyContent: 'center',
  },
  heading: {
    fontSize: 20,
    textAlign: 'center',
    marginBottom: 20,
  },
  iconContainer: {
    marginTop: 16,
    marginBottom: 16,
    justifyContent: 'center',
    alignItems: 'center',
    textAlign: 'center',
  },
  footerTitle: {
    fontSize: 18,
    textAlign: 'center',
    color: 'grey',
  },
  footerText: {
    fontSize: 16,
    textAlign: 'center',
    color: 'grey',
  },
});

export default App;

【问题讨论】:

    标签: ios react-native icons expo


    【解决方案1】:

    听起来您的图标名称在expo/vector-icons 中不存在 也许如果您提供一些代码,排除故障会容易得多。

    【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2018-03-25
    • 1970-01-01
    • 1970-01-01
    • 2017-10-13
    • 1970-01-01
    • 2018-12-25
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多