ios - Xamarin 表单,我需要在 IOS 项目中做什么才能让照片显示在 IOS 模拟器中?

标签 ios xamarin xamarin.forms

enter image description here Android 模拟器显示照片,但当我尝试 IOS 模拟器时,照片不显示。照片位于资源中,其属性为嵌入资源。

最佳答案

来自document ,它说:

Prior to iOS 9, images were typically placed in the Resources folder with Build Action: BundleResource. However, this method of working with images in an iOS app has been deprecated by Apple.

我刚刚在iOS上做了一个测试,发现如果你将照片放入资源中,它仍然有效。正确的做法是:

如果您使用.jpg照片,则必须写下全名(我猜您错过了.jpg):

<Image Source="logo.jpg" />

如果您使用 .png 照片,则可以仅使用照片的名称:

<Image Source="logo" />

我不建议您以这种方式添加照片,因为 Apple 已弃用。现在,Apple 建议您将图像添加到 Assets 目录图像集:

转到Assets.xcassets -> 新建新图像集 -> 在那里添加您的照片(1x,2x,3x)。

document中有详细步骤您可以关注。

关于ios - Xamarin 表单,我需要在 IOS 项目中做什么才能让照片显示在 IOS 模拟器中?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56049555/

相关文章:

ios - 使用 Firebase 检索的数据设置变量

c# - 即使数据类型相同,realm.xamarin 也会出现错误 "Data type mismatch"

android - 打开安全的 websocket 连接时出现意外异常

android - 在 Xamarin Forms 中处理不同设备尺寸的缩放

c# - Xamarin.Forms 属性未保存在 Android 上的 Release 中

ios - Facebook SDK 3.1 for iOS,通过应用程序切换登录时永远不会调用完成处理程序

iphone - 如何在 UIImageView 中显示高分辨率图像

c# - 以 Xamarin 形式实现视频通话,我有哪些选择?

Azure Blob 存储 - 发送图像名称列表并获取图像列表

objective-c - 来自 TableView Controller 的多个 segue