我在 MAUI 应用程序中使用 TabbedPage 时遇到问题。
该组件在 Android 上工作正常,选项卡按预期工作,但在 iOS 上,它根本不起作用,它只显示一个空白页面,其中没有任何内容,没有错误,没有崩溃,只是一片空白。
我正在使用 Visual Studio 2022 预览版。
在 macOS (Monterey) 上的 iOS 模拟器 (iPhone 13 Pro) 上运行的打印结果:
在 Android 上运行的打印结果(真实设备、Poco X3 Pro、MIUI 12.5.7、Android 11):
这是 TabbedPage 的 XAML 代码:
<?xml version="1.0" encoding="utf-8" ?>
<TabbedPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="AppColetaLeite.LinhasColeta"
NavigationPage.HasNavigationBar="false"
Title="hello">
<ContentPage Title="Tab 1">
</ContentPage>
<ContentPage Title="Tab 2">
</ContentPage>
<ContentPage Title="Tab 3">
</ContentPage>
</TabbedPage>
这是此页面的隐藏代码:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AppColetaLeite
{
public partial class LinhasColeta : TabbedPage
{
public LinhasColeta()
{
InitializeComponent();
}
}
}
最佳答案
我建议使用 Shell,直到毛伊岛变得更加稳定并支持所有平台上的控件。
<Application.MainPage>
<Shell BackgroundColor="LightGray">
<TabBar >
<Tab Title="Home" Icon="tab_home.png">
<ShellContent ContentTemplate="{DataTemplate local:ClassesPage}"/>
</Tab>
<Tab Title="Favorites" Icon="tab_favorites.png">
<ShellContent ContentTemplate="{DataTemplate local:GuardientsPage}"/>
</Tab>
<Tab Title="Map" Icon="tab_map.png">
<ShellContent ContentTemplate="{DataTemplate local:StaffPage}"/>
</Tab>
<Tab Title="Settings" Icon="tab_settings.png">
<ShellContent ContentTemplate="{DataTemplate local:MenuPage}"/>
</Tab>
</TabBar>
</Shell>
</Application.MainPage>
关于c# - TabbedPage 无法在使用 MAUI 的 iOS 上工作,而是显示空白页面,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/70879116/