【问题标题】:react native image from filesystem not displaying in ios来自文件系统的本机图像反应未在 ios 中显示
【发布时间】:2020-11-25 00:45:17
【问题描述】:

react native 镜像不出现但占用空间。它是手机文件系统上的文件,而不是相机胶卷。它是 react-native-image-editor 的产物。

尝试使用带和不带'file://'前缀的路径。在安卓上运行良好。如果我从 IOS 模拟器中获取 uri 并将其粘贴到 chrome 中,则会出现图片。使用来自网络的图片也不起作用,这让我认为这与样式有关。

const ImageAnalysis = (props) => {
  const windowWidth = useWindowDimensions().width;
  console.log(props.source);
  const imageSource = props.source;
  // const imagey = require(props.source.uri);
  const realPath =
    Platform.OS === 'ios'
      ? imageSource.uri.replace('file://', '')
      : imageSource.uri;
  console.log(realPath);
  console.log(windowWidth);
  return (
    <View
      style={{
        flex: 2,
        flexDirection: 'row',
        borderBottomColor: colors.BrinkPink,
        // backgroundColor: colors.RoyalPurple,
        borderBottomWidth: 1,
      }}>
      <Image
        source={{uri: props.source.uri}}
        resizeMode="contain"
        style={{
          // position: 'relative',
          height: windowWidth / 3,
          width: windowWidth / 3,
          borderRadius: windowWidth / 3,
          margin: windowWidth / 12,
          alignSelf: 'center',
        }}
      />

【问题讨论】:

    标签: ios react-native


    【解决方案1】:

    原来这是 React Native 0.63.0 和 iOS 14 的错误。升级到 React Native 0.63.2 修复了它。

    【讨论】:

      猜你喜欢
      • 2021-09-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-04-15
      • 1970-01-01
      • 2011-05-18
      • 2021-03-11
      • 2021-05-24
      相关资源
      最近更新 更多