本文介绍了React Native应用程序中的所有图像/快速图像在iOS 14 beta和Xcode 12 beta中不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已将iPhone设备升级到iOS 14 beta和Xcode 12 beta.然后,我的React Native项目上的所有图像/快速图像都无法显示(在以前的iOS 13和Xcode 11.5上运行良好).

I've upgraded my iPhone device to iOS 14 beta and Xcode 12 beta. Then all Image/Fast Image on my React Native project can not show (which work well on previous iOS 13 and Xcode 11.5).

推荐答案

按照此处的建议尝试使用react-native+0.63.0.patch https://github.com/facebook/react-native/issues/29279

Try using react-native+0.63.0.patch as suggested here https://github.com/facebook/react-native/issues/29279

diff --git a/node_modules/react-native/Libraries/Image/RCTUIImageViewAnimated.m b/node_modules/react-native/Libraries/Image/RCTUIImageViewAnimated.m
index 21f1a06..2444713 100644
--- a/node_modules/react-native/Libraries/Image/RCTUIImageViewAnimated.m
+++ b/node_modules/react-native/Libraries/Image/RCTUIImageViewAnimated.m
@@ -272,6 +272,9 @@ - (void)displayDidRefresh:(CADisplayLink *)displayLink
 
 - (void)displayLayer:(CALayer *)layer
 {
+  if (!_currentFrame) {
+    _currentFrame = self.image;
+  }
   if (_currentFrame) {
     layer.contentsScale = self.animatedImageScale;
     layer.contents = (__bridge id)_currentFrame.CGImage;
diff --git a/node_modules/react-native/scripts/.packager.env b/node_modules/react-native/scripts/.packager.env
new file mode 100644
index 0000000..361f5fb
--- /dev/null
+++ b/node_modules/react-native/scripts/.packager.env
@@ -0,0 +1 @@
+export RCT_METRO_PORT=8081

使用补丁
运行npm i -g patch-package
新建一个名为patchs的文件夹
在该文件夹中新建一个名为react-native + 0.63.0.patch的文件
在上方添加源代码
在项目

To use the patch
run npm i -g patch-package
Make a new folder called patches
Make a new file called react-native+0.63.0.patch inside that folder
Add the source code above
run patch-package on the root of the project

这篇关于React Native应用程序中的所有图像/快速图像在iOS 14 beta和Xcode 12 beta中不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-25 02:13