我有一个 react native 应用程序,需要显示产品的图像,如果他们存在. 我将Base64编码的图像作为BLOB存储在本地SQLite上,并按如下方式呈现它们:

<Image source={{uri: "data:image/png;base64," + imgsource}} style={{height: 150, width: null, flex: 1}}/>

其中,imgsource是从数据库检索到的Base64字符串.图像和其他信息直接从数据库存储在对象数组中.

我正在使用Reaction Native 0.61.5

在安卓上,一切都运行得很好,但在iOS上,图像不会被显示.我是不是遗漏了什么?

Podfile

platform :ios, '9.0'
require_relative '../node_modules/@react-native-community/cli-platform-ios/native_modules'
project 'sgeapp.xcodeproj'
target 'sgeapp' do
  # Pods for sgeapp
  pod 'FBLazyVector', :path => "../node_modules/react-native/Libraries/FBLazyVector"
  pod 'FBReactNativeSpec', :path => "../node_modules/react-native/Libraries/FBReactNativeSpec"
  pod 'RCTRequired', :path => "../node_modules/react-native/Libraries/RCTRequired"
  pod 'RCTTypeSafety', :path => "../node_modules/react-native/Libraries/TypeSafety"
  pod 'React', :path => '../node_modules/react-native/'
  pod 'React-Core', :path => '../node_modules/react-native/'
  pod 'React-CoreModules', :path => '../node_modules/react-native/React/CoreModules'
  pod 'React-Core/DevSupport', :path => '../node_modules/react-native/'
  pod 'React-RCTActionSheet', :path => '../node_modules/react-native/Libraries/ActionSheetIOS'
  pod 'React-RCTAnimation', :path => '../node_modules/react-native/Libraries/NativeAnimation'
  pod 'React-RCTBlob', :path => '../node_modules/react-native/Libraries/Blob'
  pod 'React-RCTImage', :path => '../node_modules/react-native/Libraries/Image'
  pod 'React-RCTLinking', :path => '../node_modules/react-native/Libraries/LinkingIOS'
  pod 'React-RCTNetwork', :path => '../node_modules/react-native/Libraries/Network'
  pod 'React-RCTSettings', :path => '../node_modules/react-native/Libraries/Settings'
  pod 'React-RCTText', :path => '../node_modules/react-native/Libraries/Text'
  pod 'React-RCTVibration', :path => '../node_modules/react-native/Libraries/Vibration'
  pod 'React-Core/RCTWebSocket', :path => '../node_modules/react-native/'

  pod 'React-cxxreact', :path => '../node_modules/react-native/ReactCommon/cxxreact'
  pod 'React-jsi', :path => '../node_modules/react-native/ReactCommon/jsi'
  pod 'React-jsiexecutor', :path => '../node_modules/react-native/ReactCommon/jsiexecutor'
  pod 'React-jsinspector', :path => '../node_modules/react-native/ReactCommon/jsinspector'
  pod 'ReactCommon/jscallinvoker', :path => "../node_modules/react-native/ReactCommon"
  pod 'ReactCommon/turbomodule/core', :path => "../node_modules/react-native/ReactCommon"
  pod 'Yoga', :path => '../node_modules/react-native/ReactCommon/yoga'

  pod 'DoubleConversion', :podspec => '../node_modules/react-native/third-party-podspecs/DoubleConversion.podspec'
  pod 'glog', :podspec => '../node_modules/react-native/third-party-podspecs/glog.podspec'
  pod 'Folly', :podspec => '../node_modules/react-native/third-party-podspecs/Folly.podspec'


#  pod 'RNVectorIcons', :path => '../node_modules/react-native-vector-icons'
  pod 'react-native-sqlite-storage', :path => '../node_modules/react-native-sqlite-storage'
  target 'sgeappTests' do
    inherit! :search_paths
    # Pods for testing
  end

  post_install do |installer|
      ## Fix for XCode 12.5 beta
      find_and_replace("../node_modules/react-native/React/CxxBridge/RCTCxxBridge.mm", "_initializeModules:(NSArray<id<RCTBridgeModule>> *)modules", "_initializeModules:(NSArray<Class> *)modules")
          find_and_replace("../node_modules/react-native/ReactCommon/turbomodule/core/platform/ios/RCTTurboModuleManager.mm", "RCTBridgeModuleNameForClass(strongModule))", "RCTBridgeModuleNameForClass(Class(strongModule)))")
  end
  
  use_native_modules!
end

def find_and_replace(dir, findstr, replacestr)
  Dir[dir].each do |name|
      text = File.read(name)
      replace = text.gsub(findstr,replacestr)
      if text != replace
          puts "Fix: " + name
          File.open(name, "w") { |file| file.puts replace }
          STDOUT.flush
      end
  end
  Dir[dir + '*/'].each(&method(:find_and_replace))
end

推荐答案

经过一些额外的研究,我发现这是xcode12和Reaction版本0.63.2中构建的错误

查看https://stackoverflow.com/a/68906311/12493015以了解适用于我的解决方案

因此,如果其他任何人遇到此问题,要么判断链路上的解决方案,要么升级到本机版本0.63.2或更高版本

Ios相关问答推荐

Swift addtarget方法的默认参数不生效

在带有可编码的SWIFT5中,可以轻松处理以美元符号开头的JSON密钥,例如$DATE";

删除领域中的cartItem时出现问题

如何解释在SwiftUI视图中观察到持续的数据更改

以编程方式更改VC&39;S导航栏按钮的属性,以响应另一个VC中的按钮按下

Swift在SceneKit中为scnnode添加自定义几何体(视图)

Xamarin Forms CustomPin iOS Render

如何防止UITest套件与Fastlane一起执行?

iOS应用程序冻结在UICollectionView代码,但我没有';没有任何UICollectionViews

部分保留 UITextField 中的占位符

Flutter iOS 构建失败:DVTCoreDeviceEnabledState_Disabled

通过函数使用 Gesture 时,键入任何视图不能符合视图

用溢出的长文本对齐 Flutter 中的行和列

SwiftUI:添加核心数据项时更新选项卡栏徽章

在 UITextView 中垂直居中文本

在主线程上发布 NSNotification

如何使用 sendAsynchronousRequest:queue:completionHandler:

iOS - 确保在主线程上执行

判断可选数组是否为空

核心数据 - 无法在路径加载优化模型