Image Xamarin.Forms iOS图像不显示
我有一个Xamarin.Forms共享项目。在Android上,所有图像都可以正常工作。我想将它们添加到我的iOS项目中,但它们没有显示出来。我已将它们添加到Assets.xAssets:Image Xamarin.Forms iOS图像不显示,image,xaml,xamarin.forms,xamarin.ios,Image,Xaml,Xamarin.forms,Xamarin.ios,我有一个Xamarin.Forms共享项目。在Android上,所有图像都可以正常工作。我想将它们添加到我的iOS项目中,但它们没有显示出来。我已将它们添加到Assets.xAssets: { "filename": "logo_launcher.png", "scale": "1x", "idiom": "universal" } 我使用以下XAML: <Image Source="logo_launcher.png" x:Name="logo" /> 我添加了
{
"filename": "logo_launcher.png",
"scale": "1x",
"idiom": "universal"
}
我使用以下XAML:
<Image Source="logo_launcher.png" x:Name="logo" />
我添加了除矢量图像以外的所有图像。我正在iPhone8-11.4模拟器上测试它
虽然不推荐使用,但我尝试将图像添加到“资源”文件夹中。但我甚至无法选择.png文件。所以这也没用
我不知道该怎么办。我是否需要启用一些选项,或者在XAML中包含一些东西以使其工作?检查/重现以下一些步骤:
嵌入式资源
,在Android中,构建操作应该是Android资源
和iOS中的捆绑资源
复制到输出目录
设置为始终复制
ImageSource
,如下所示:
<Image x:Name="logo">
<Image.Source>
<OnPlatform x:TypeArguments="ImageSource">
<On Platform="Android" Value="logo_launcher.png"/>
<On Platform="iOS" Value="logo_launcher"/>
</OnPlatform>
</Image.Source>
</Image>
我希望这能对您有所帮助。也许我发现了一个使用Assets.xcsets的方法,请检查以下步骤:
<Image x:Name="iconBrain">
<Image.Source>
<OnPlatform x:TypeArguments="ImageSource">
<OnPlatform.iOS><FileImageSource File="IconBrain"/></OnPlatform.iOS>
<OnPlatform.Android><FileImageSource File="ic_brain"/></OnPlatform.Android>
</OnPlatform>
</Image.Source>
</Image>
我希望这能对您有所帮助。只需在ios中选择resources文件夹中的所有图像,
右键单击-->构建操作-->捆绑资源
。它将起作用。无法评论,但请检查以下答案:我遵循了这一点,不幸的是,这对我不起作用。有一个变化,我很愚蠢,但我无法在assets.xcsets目录中执行步骤1和2。其他步骤不成功。您不需要使用assets.xAssetsYes I do:“在iOS 9之前,图像通常与BundleResource一起放置在Resources文件夹中。但是,Apple不赞成在iOS应用程序中使用图像的这种方法。有关更多信息,请参阅图像大小和文件名。”我不知道,我去看看。Tksbro@TruffelNL请检查我找到的可能的解决方案。