You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

MAUI中HorizontalStackLayout在iOS上无法显示图片求助

MAUI图片在iOS设备上不显示的问题

我有一个包含2行1列Grid的页面,Grid内的HorizontalStackLayout组件中放置了两张dotnet_bot图片。这些图片在Android设备(华为、三星真机)上正常显示,但在iOS设备(iPhone 8真机及iPhone13/14模拟器)上完全不可见。我尝试移除HorizontalStackLayout,将父Grid设置为2列布局,结果依然相同。

第一种实现(使用HorizontalStackLayout)

<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
         xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
         x:Class="Testapp2.MainPage">

<Grid RowDefinitions="25*,75*" ColumnDefinitions="100*">

    <HorizontalStackLayout HorizontalOptions="CenterAndExpand">
        <Image Source="dotnet_bot.png" Scale="1" Aspect="AspectFit"/>
        <Image Source="dotnet_bot.png" Scale="1" Aspect="AspectFit"/>
</Grid>
</ContentPage>

第二种实现(不使用HorizontalStackLayout)

<Grid RowDefinitions="25*,75*" ColumnDefinitions="50*,50*">
        <Image Grid.Column="0" Source="dotnet_bot.png" Scale="1" Aspect="AspectFit"/>
        <Image Grid.Column="1" Source="dotnet_bot.png" Scale="1" Aspect="AspectFit"/>
</Grid>

显示效果对比

  • Android正常显示:Android正常显示
  • iOS显示异常:iOS显示异常

内容的提问来源于stack exchange,提问作者Luis Guzman

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.17 09:57:24