Really basic Xamarin iOS tabbed app freezes when tapping More

120 Views Asked by At

I wrote an incredibly basic tabbed app in Xamarin with 6 tabs (so it provides a More menu). Weirdly, tapping More -> Page and then on the More button causes the app to freeze on iOS.

Here is the entirety of the page code:

public partial class MainPage : TabbedPage
{
    public MainPage()
    {
        InitializeComponent();

        SetupTabs();
    }

    void SetupTabs()
    {
        for(var index = 0; index < 6; index++)
            AddPage();
    }

    void AddPage()
    {
        NavigationPage navPage = new NavigationPage(new Page());
        navPage.Title = "Page";

        Children.Add(navPage);
    }
}

And here's the xaml:

<?xml version="1.0" encoding="utf-8" ?>
<TabbedPage xmlns="http://xamarin.com/schemas/2014/forms"
        xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
        x:Class="testTabs2.MainPage" />

What on earth could I have done wrong here?

Curiously, if I add Pages, rather than NavigationPages the app is fine but, as far as I can tell, there is nothing wrong with adding NavigationPages as the children of a tabbed page.

1

There are 1 best solutions below

0
Guangyu Bai - MSFT On

You can check this issue about Apps sometimes freeze/hang on iOS 15. It is a navigation issue on iOS. You can check this answer about Override Dispose for more information.