首页 > 解决方案 > 图像随着警报消失

问题描述

描述

当应用程序触发警报(来自 Alert 命名空间)时,屏幕上呈现的所有本地图像都会在 iOS 上消失。

反应原生版本:

0.63.2 世博 SDK v40.0.0

重现步骤

提供重现问题的详细步骤列表。

  1. 打造世博小吃
  2. 创建一个 Pressable 组件(Pressable、Button、TouchableOpacity 等...)
  3. 创建图像
  4. 设置 onPress 属性以调用触发警报的函数。
  5. 切换到 iOS 标签并点击 Tap to Play

预期成绩

警报触发并且图像保持在屏幕上呈现

小吃、代码示例、屏幕截图或存储库链接:

https://snack.expo.io/@razorshnegax/1f5b93'

代码示例:

import React from 'react';
import { Text, View, Button, Image, Alert } from 'react-native';

export default class Index extends React.Component {
  render() {
    return (
      <View>
        <Button
          onPress={() => {
            let eer = 'ees';
            // Fires the alert
            Alert.alert(eer);
          }}
          title="yeep"
        />
        // The image that dissappears
        <Image source={require('./image.gif')} />
      </View>
    );
  }
}

标签: reactjsreact-native

解决方案


这是因为您使用的是“gif”,而不是图像。来自 iOS 中的图像react-native不支持 gif。 来源

If you replace it with a png file, it won't disappear.


推荐阅读