反应来自文件系统的本机图像未在ios中显示

时间:2020-08-04 21:05:48

标签: ios react-native

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

尝试使用带和不带'file://'前缀的路径。在android上工作正常。如果我从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',
        }}
      />

1 个答案:

答案 0 :(得分:0)

原来这是React Native 0.63.0和iOS 14的一个错误。升级到React Native 0.63.2可以解决。