React Native Image不在iOS上显示

问题描述 投票:0回答:1

我已在现有应用程序内集成了本机反应,这是没有问题的。在我的反应代码中添加了本地图像,这在Android中正常工作但未在iOS中显示(既不是模拟器也不是设备)。这是我的代码

 <TouchableHighlight
key={j + 3000}
style={{ width: 24, height: 24, paddingLeft: 5, paddingTop: 2 }}
onPress={() => this._showAlert(textItem.popText)}
>
<Image
    style={{ width: 13, height: 13, opacity: 0.7 }}
    source={require("./img/info.png")}
   />
</TouchableHighlight>;

任何人都可以在这里建议我做错了什么。似乎反应可以找到图像,因为它没有显示任何错误但没有显示任何图像,而是显示红色边框。

react-native-ios react-native-image
1个回答
0
投票

事实证明,在pods中我不得不添加'RCTImage'来显示图像

pod 'React', :path => ‘node_modules/react-native', :subspecs => [
    'Core',
    'DevSupport', # Include this to enable In-App Devmenu if RN >= 0.43
    'RCTText',
    'RCTImage',
    'RCTNetwork',
    'BatchedBridge',
    'RCTWebSocket', # needed for debugging

'RCTAnimation'
    # Add any other subspecs you want to use in your project
]
© www.soinside.com 2019 - 2024. All rights reserved.