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正常显示:

- iOS显示异常:

内容的提问来源于stack exchange,提问作者Luis Guzman
相关产品推荐
相关产品推荐

