c# - TabbedPage 无法在使用 MAUI 的 iOS 上工作,而是显示空白页面

标签 c# ios xamarin visual-studio-2022 maui

我在 MAUI 应用程序中使用 TabbedPage 时遇到问题。

该组件在 Android 上工作正常,选项卡按预期工作,但在 iOS 上,它根本不起作用,它只显示一个空白页面,其中没有任何内容,没有错误,没有崩溃,只是一片空白。

我正在使用 Visual Studio 2022 预览版。

在 macOS (Monterey) 上的 iOS 模拟器 (iPhone 13 Pro) 上运行的打印结果: iOS Simulator iPhone 13 Pro

在 Android 上运行的打印结果(真实设备、Poco X3 Pro、MIUI 12.5.7、Android 11): Real device, 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/

相关文章:

c# - 通过C#将回车符传递给SQL SP

iphone - 替换NSString中的字符列表

ios - UIView > SKView ... willMoveFromView : not being called when expected and sprites not being "updated"

linq - Xamarin Forms - 如何从 MergedDictionaries 中选择 C# 中的资源

c# - 在 Spritekit 中固定大小

c# - 如果我使用 HMACSha1 作为哈希算法,为什么 PasswordDeriveBytes 每次都会生成不同的 key ?

c# - 如何定期截断 Microsoft Azure 上的 SQL 数据库

xamarin.ios - Xamarin iOS 8 捆绑资源 - 访问路径被拒绝

c# - 使用 C# 和 OleDbConnection 从特定工作表的 Excel 文件中获取列名称

ios - UNUserNotificationCenterDelegate 方法未被调用 Xcode 8 iOS 10