简体   繁体   English

使用React Native图像会在重新加载应用程序一段时间后消失

[英]With React Native images disappear after some time when app is reloaded

When I include static images in my React Native apps (tested only on Android) everything works fine, also on a real device, in the beginning . 当我在我的React Native应用程序中包含静态图像(仅在Android上测试)时,一切正常,也可以在真实设备上开始 After some time, on the real device, when the app is reloaded, all images are gone (not visible). 一段时间后,在真实设备上,当重新加载应用程序时,所有图像都消失了(不可见)。 I can reproduce this very easy, simply by creating a new project (react-native init myDemo) and then add some images, using code exactly as described in the Docs. 我可以通过创建一个新项目(react-native init myDemo)然后添加一些图像,使用完全如文档中所述的代码来重现这一点。 The code below is my code inserted into a plain new React Native app, and it suffers from the exact same problem (for all the images). 下面的代码是我的代码插入一个普通的新React Native应用程序,它遇到了完全相同的问题(对于所有图像)。

return (
  <View style={styles.container}>
    <View style={{justifyContent: 'center', alignItems: 'center',}}>
      <Image source={require("./img/blue.png")}/>
    </View>
    <View>
      <Image resizeMode="cover" source={require("./img/red.png")}/>
    </View>
    <View>
      <Image resizeMode="contain" source={require("./img/green.png")}/>
    </View>
    <View>
      <Image resizeMode="stretch" source={require("./img/orange.png")}/>
    </View>
    <Image style={{width: 51, height: 50}} source={require("./img/black.png")}/>
  </

View> ); 查看>);

Is this a general Android problem with React Native, or am I missing something here? 这是React Native的一般Android问题,还是我在这里遗漏了什么? Before you mark this a duplicate of other questions, if have tried the following suggestions from similar questions: 在您将此标记与其他问题重复之前,如果您尝试过类似问题的以下建议:

  • android:largeHeap="true" 机器人:largeHeap = “真”
  • Ad an eventListener to AppState. 向AppState发送eventListener。

my problem was simply with uuid package that i had used to produce a unique identifier for the users that doesn't like to register. 我的问题只是使用uuid包,我曾经习惯为不喜欢注册的用户生成一个唯一的标识符。

I even had another problem with this package too. 我甚至还有这个包的另一个问题。 It made one of the reactNative apps on my device to logout automatically without any reason! 它使我的设备上的一个reactNative应用程序无需任何理由自动注销!

removing this package reverted everything to natural condition. 删除此包将所有内容恢复到自然状态。

Hope this answer help you too. 希望这个答案对你有帮助。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 React Native 本地资产图像在发布模式下没有显示一段时间 - React Native local assets images not showing some time on release mode Android通知会在一段时间后消失 - Android Notifications disappear after some time 加载后 Android 启动画面应用程序图标不会消失 - React Native - Android Splash Screen App Icon won't disappear after loading - React Native 应用程序在一段时间后从后台恢复时重新启动 - App restarts when resuming from background after some time 在您的应用未激活/正在运行一段时间后,请执行操作 - Do action after some time when your app is not active / running 当用户在一段时间后恢复应用程序时,是否响应本机,刷新活动? - React Native, refresh activity when user resumes app after a while? 当应用程序被杀死时,活动出现几秒钟然后在 android 中消失(SINCH) - When app is killed activity appear for some second then disappear in android (SINCH ) 安装 react-navigation 5 后,应用程序在使用 React Native CLI 启动时崩溃 - App crashes on launch time with react native CLI after installing react-navigation 5 React Native:uri 图像显示黑色块,一段时间后应用程序崩溃 - React Native: uri image display black block, after some moment app crash 如何创建某种Splash屏幕/启动屏幕,在App加载后消失? (React Native) - How to create some kind of Splash screen/Launching screen, which disappears after App loaded? (React Native)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM