Wednesday, February 25, 2026
HomeiOS Development.NET MAUI: The tab switching performance just isn't working correctly on the...

.NET MAUI: The tab switching performance just isn’t working correctly on the iOS platform


We’ve got three tabs in our utility. Initially, switching from the primary tab to the third tab works superb. Nevertheless, when making an attempt to change again from the third tab to the primary tab, it doesn’t work as anticipated. As a substitute, it navigates from the third tab to the second tab, and solely then permits switching to the primary tab. This challenge happens solely on the iOS platform and works superb on Android Platform.

The primary tab is a CarouselPage, whereas the opposite two tabs are ContentView pages. After logging into the app, the three tabs seem. From the CarouselPage, I’m utilizing WeakReferenceMessenger to deal with the swiping between tabs ranging from the primary web page. Beneath is a pattern code snippet for sending the WeakReferenceMessenger:


    
        
            
            
            
        
    
    
        
            
        
    


void OnCurrentItemChanged(object sender, CurrentItemChangedEventArgs e)
{
    attempt
    {
        Debug.WriteLine("Place:>>" + carouselView.Place);
        int index = carouselView.Place;
        AddWeakReferenceMessenger(index);
    }
    catch (Exception ex)
    {
        Debug.WriteLine("Exception:>>" + ex);
    }
}

personal void AddWeakReferenceMessenger(int index)
{
    attempt
    {
        if (index == 0)
        {
            WeakReferenceMessenger.Default.Ship(new HomeTabChangeMessage("home_tab"));
        }
        else if (index == 1)
        {
            WeakReferenceMessenger.Default.Ship(new HomeTabChangeMessage("friends_tab"));
        }
        else if (index == 2)
        {
            WeakReferenceMessenger.Default.Ship(new HomeTabChangeMessage("history_tab"));
        }
    }
    catch (Exception ex)
    {
        Debug.WriteLine("Exception:>>" + ex);
    }
}

This WeakReferenceMessenger is registered to every tab. Beneath is a pattern code snippet for third tab to subscribe to the message.

WeakReferenceMessenger.Default.Register(this, async (r, m) =>
{
    if (m.Worth == "history_tab")
    {
        Debug.WriteLine("isHistoryLoaded:>>" + Utility.isHistoryLoaded);
        if (!Utility.isHistoryLoaded)
        {
            UserDialogs.Occasion.ShowLoading("");
            await Process.Delay(TimeSpan.FromSeconds(0.25));
            Utility.isHistoryLoaded = true;
            await Process.Run(async () => await SetHistoryListItems());
        }
        WeakReferenceMessenger.Default.Unregister(this);
    }
});

Beneath is a pattern code snippet for sending the WeakReferenceMessenger for switching from third tab to first tab:

public void ShowHome(object sender, EventArgs args)
{
    WeakReferenceMessenger.Default.Ship(new TabSelectionMessage("child-0"));
}

Beneath is a pattern code snippet for first tab to subscribe to the message.

WeakReferenceMessenger.Default.Register(this, (r, m) =>
{
    attempt
    {
        string[] childArray = m.Worth.Break up("-");
        if (childArray[0] == "little one")
        {
            carouselView.ScrollTo(Int32.Parse(childArray[1]));
            AddWeakReferenceMessenger(Int32.Parse(childArray[1]));
        }
    }
    catch (Exception ex)
    {
        Debug.WriteLine("TabSelectionException>>:" + ex);
    }
});

Can u please present an answer for this challenge?

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments