.NET MAUI在iOS端无法全屏显示(底部黑条),Android端正常
.NET MAUI iOS端底部黑条+导航栏过高问题解决思路
检查安全区域配置
迁移后的项目可能没正确适配iOS安全区域,在MenuPage或其他ContentPage的XAML里加上UseSafeArea="true",或者初始化NavigationPage时确认安全区域生效:MainPage = new NavigationPage(new MenuPage()) { BarBackgroundColor = Color.FromHex("#你的导航栏颜色"), BarTextColor = Color.White };同时检查
Info.plist关联的启动屏幕(LaunchScreen.storyboard),确保布局约束绑定到安全区域——旧Xamarin的启动屏可能没做适配,导致MAUI识别出错。修复导航栏高度异常
项目可能残留了Xamarin的导航栏样式配置,在iOS项目的AppDelegate.cs里重置导航栏样式:public override bool FinishedLaunching(UIApplication app, NSDictionary options) { // 保留原有代码 UINavigationBar.Appearance.Translucent = false; UINavigationBar.Appearance.ShadowImage = new UIImage(); UINavigationBar.Appearance.SetBackgroundImage(new UIImage(), UIBarMetrics.Default); return base.FinishedLaunching(app, options); }也可以在ContentPage构造函数里手动指定导航栏相关属性:
NavigationPage.SetHasNavigationBar(this, true); NavigationPage.SetTitleView(this, new Label { Text = "标题", FontSize = 18 });清理Xamarin残留配置
打开项目的.csproj文件,检查是否还有Xamarin.Forms相关的NuGet引用或配置,全部替换成MAUI的包。然后删除bin和obj文件夹,重新生成解决方案,避免旧编译文件干扰。强制安全区域适配
如果上面的方法都没用,试试在iOS项目的SceneDelegate.cs里手动触发安全区域更新:public override void WillConnect(UIScene scene, UISceneSession session, UISceneConnectionOptions connectionOptions) { base.WillConnect(scene, session, connectionOptions); if (Window != null) { Window.SafeAreaInsetsDidChange(); Window.RootViewController = new UIHostingViewController(MauiProgram.CreateMauiApp().Services.GetRequiredService<IMauiContext>().NavigationRootManager.RootViewController); } }
内容的提问来源于stack exchange,提问作者smallscreensw
相关产品推荐
相关产品推荐

