ios - XCode 12.3 上的 ReactNative 0.59.10 未显示照片
问题描述
我正在处理一个旧的现有 ReactNative 项目。我在应用程序中显示照片时遇到问题。当我使用 Xcode 11.x 时,该应用程序很好。然后我开始使用 Xcode 12.3。当我在 Xcode 12.3 上构建项目时,它不再显示照片。这似乎是 Xcode 12.3 上 ReactNative 的一个已知问题。
我的 ReactNative 版本是 0.59.10。我正在关注这篇文章来解决这个问题,https://infinitbility.com/image-not-showing-in-ios-14-react-native。但它不起作用。
这是我到目前为止所做的。我安装了运行以下 npm 命令的补丁包。
npm install -g patch-package
然后我在项目的根文件夹中创建了一个补丁文件夹。然后我在 patchs 文件夹中创建了一个名为 patch/react-native+0.59.10.patch 的文件,其内容如下。
diff --git a/node_modules/react-native/Libraries/Image/RCTUIImageViewAnimated.m b/node_modules/react-native/Libraries/Image/RCTUIImageViewAnimated.m
2index 21f1a06..2444713 100644
3--- a/node_modules/react-native/Libraries/Image/RCTUIImageViewAnimated.m
4+++ b/node_modules/react-native/Libraries/Image/RCTUIImageViewAnimated.m
5@@ -272,6 +272,9 @@ - (void)displayDidRefresh:(CADisplayLink *)displayLink
6
7 - (void)displayLayer:(CALayer *)layer
8 {
9+ if (!_currentFrame) {
10+ _currentFrame = self.image;
11+ }
12 if (_currentFrame) {
13 layer.contentsScale = self.animatedImageScale;
14 layer.contents = (__bridge id)_currentFrame.CGImage;
15diff --git a/node_modules/react-native/scripts/.packager.env b/node_modules/react-native/scripts/.packager.env
16new file mode 100644
17index 0000000..361f5fb
18--- /dev/null
19+++ b/node_modules/react-native/scripts/.packager.env
20@@ -0,0 +1 @@
21+export RCT_METRO_PORT=8081
然后我运行以下命令来应用修复。
patch-package
我得到以下输出。
然后我关闭了 Xcode 并再次打开它。它仍然没有显示照片。我该如何解决?
解决方案
推荐阅读
- ios - 如何使用 iOS-Charts 创建具有多个 labelTextColor YAxis 的 LineChartView
- android - 如何使用 Kotlin 在 Android 上的 Apollo GraphQL 中创建 JSON CustomTypeAdapter
- azure - Azure Blob 存储 SDK:关闭日志记录
- python - 如何从路线中找到一个位置的最短距离(Python),
- perl - perl 使用评估修饰符在字符串中增加数字
- continuous-integration - 来自 Go CI/CD 的 Gitlab 连接
- opencv - Unity3D中如何检测人体
- cpu-architecture - 变量分配和 RAM
- javascript - 使用 JavaScript 且不使用 PostBack() 的用户控件 (ascx) 中的 SET 父页面 (aspx) 标签文本
- javascript - 在 div 转换时修复孩子的位置