gpt4 book ai didi

ios - 通过 https 的 React-native 加载图像有效,而 http 无效

转载 作者:可可西里 更新时间:2023-11-01 03:39:03 26 4
gpt4 key购买 nike

我想通过 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>
);
}

最佳答案

问题是您正在尝试从 http 连接加载图像,而不是 apple 要求的从 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 文件并在那里添加你的异常(exception)。更多详细信息在这里 https://ste.vn/2015/06/10/configuring-app-transport-security-ios-9-osx-10-11/

关于ios - 通过 https 的 React-native 加载图像有效,而 http 无效,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38153335/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com