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

Maui.NET iOS平台Shell.FlyoutContent显示空白问题求解

修复MAUI Shell在iOS上FlyoutContent空白的问题

问题原因

iOS平台下,Shell.FlyoutContent 内部的布局默认不会自动填充可用空间,若未明确设置布局约束或尺寸,内容会因无有效空间约束而无法显示。

修复方案

方案1:为FlyoutContent内的布局添加扩展属性

修改Shell.FlyoutContent中的Frame,设置HorizontalOptions和VerticalOptions为FillAndExpand,让布局填满Flyout的可用空间:

<Shell.FlyoutContent>
    <Frame BackgroundColor="ForestGreen"
           HorizontalOptions="FillAndExpand"
           VerticalOptions="FillAndExpand">
        <Label Text="hello"
               HorizontalOptions="Center"
               VerticalOptions="Center"/>
    </Frame>
</Shell.FlyoutContent>

方案2:改用FlyoutHeader替代FlyoutContent(适合顶部固定内容)

如果你的Flyout内容属于头部区域,使用Shell.FlyoutHeader可以自动适配iOS平台的空间规则:

<Shell.FlyoutHeader>
    <Frame BackgroundColor="ForestGreen"
           HorizontalOptions="FillAndExpand"
           VerticalOptions="FillAndExpand">
        <Label Text="hello"
               HorizontalOptions="Center"
               VerticalOptions="Center"/>
    </Frame>
</Shell.FlyoutHeader>

方案3:明确设置内容尺寸(适配特定场景)

直接指定Frame的宽高尺寸,强制内容显示(需注意不同设备尺寸的适配性,推荐优先使用前两种方案):

<Shell.FlyoutContent>
    <Frame BackgroundColor="ForestGreen"
           WidthRequest="300"
           HeightRequest="600">
        <Label Text="hello"/>
    </Frame>
</Shell.FlyoutContent>

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.06.17 07:52:04