我想通过http uri作为源在iOS模拟器中加载图像。但是屏幕上除了线框之外什么都不显示,线框可以通过检查器显示出来。如果你在Android中加载相同的代码,它也能正常工作,如果你使用https uri而不是http,它也能正常工作。
示例代码:
render() {
return (
<View>
<Image
source={{uri:https://facebook.github.io/react/img/logo_og.png'}} // works
// source={{uri: http://facebook.github.io/react/img/logo_og.png'}} // doesn't work
style={{width: 400, height: 400}}
/>
</View>
);
}发布于 2016-07-02 04:17:19
问题是你试图从http连接加载图片,而不是像苹果要求的那样从https连接加载。如果您的代码使用另一个使用https而不是http的uri,请尝试。在Android中,它应该可以很好地与http或https一起工作。在https://github.com/facebook/react-native/issues/8520和http://www.techrepublic.com/article/wwdc-2016-apple-to-require-https-encryption-on-all-ios-apps-by-2017/上阅读更多。
如果你真的想通过http加载一些东西,你可以编辑info.plist文件并在那里添加你的异常。更多详细信息请点击此处https://ste.vn/2015/06/10/configuring-app-transport-security-ios-9-osx-10-11/
发布于 2017-10-25 18:30:04
在info.plist中添加
<key>NSAppTransportSecurity</key>
<dict>
<!--Include to allow all connections (DANGER)-->
<key>NSAllowsArbitraryLoads</key>
<true/>
</dict>https://stackoverflow.com/questions/38153335
复制相似问题