Shell back button shows a flyout menu instead of popping the page

jointothedarksidejointothedarkside Member ✭✭
edited September 30 in Xamarin.iOS

I have an app made with shell and it works properly on android, I'm trying to run it in iOS but if I tap the back button it doesn't pop the opened page it opens a flyout menu which is empty I don't know where it's coming from since I'm not using nothing like that in my project.

This is the code from my AppShell

    <?xml version="1.0" encoding="UTF-8"?>
    <Shell xmlns="http://xamarin.com/schemas/2014/forms" 
           xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" 
           xmlns:views="clr-namespace:App.Views"             
           Title="App"
           x:Class="App.AppShell"       
           Shell.NavBarIsVisible="True"
           Shell.TabBarIsVisible="True"
           Shell.FlyoutBehavior="Disabled"
           xmlns:converters="clr-namespace:App.Converters"
           >

        <!-- Styles and Resources -->
        <Shell.Resources>
            <ResourceDictionary>
                <Color x:Key="NavigationPrimary">#000000</Color>
                <Color x:Key="Bounty">#4bbcf4</Color>
                <Color x:Key="Seagreen">#61c0bf</Color>
                <Color x:Key="Oceana">#bbded6</Color>
                <Color x:Key="Rosada">#ffb6b9</Color>
                <Color x:Key="PinkSalt">#fae3d9</Color>

                <Style x:Key="BaseStyle" TargetType="Element">
                    <Setter Property="Shell.BackgroundColor" Value="{StaticResource NavigationPrimary}" />
                    <Setter Property="Shell.ForegroundColor" Value="{StaticResource Bounty}" />
                    <Setter Property="Shell.TitleColor" Value="{StaticResource Bounty}" />
                    <Setter Property="Shell.DisabledColor" Value="#B4FFFFFF" />
                    <Setter Property="Shell.UnselectedColor" Value="Purple" />
                    <Setter Property="Shell.TabBarBackgroundColor" Value="GhostWhite" />
                    <Setter Property="Shell.TabBarForegroundColor" Value="{StaticResource Seagreen}"/>
                    <Setter Property="Shell.TabBarUnselectedColor" Value="#502148ff"/>
                    <Setter Property="Shell.TabBarTitleColor" Value="#2148ff"/>                
                </Style>
                <Style TargetType="ShellItem" BasedOn="{StaticResource BaseStyle}" />
                <converters:NullableIntConverter x:Key="NullableIntConverter" />
                <converters:HtmlSourceConverter x:Key="HtmlSourceConverter" />
            </ResourceDictionary>
        </Shell.Resources>

        <!-- Your Pages -->
        <ShellItem Style="{StaticResource BaseStyle}">
            <ShellSection Title="Home" Icon="home.png" x:Name="IndexTab">
                <ShellContent Route="index"
                              Title="Home"
                              Icon="home.png"
                              x:Name="IndexContent"/>
            </ShellSection>
            <ShellSection Title="News" Icon="deck2.png" Route="news" x:Name="HomeTab">
                <ShellContent Route="news"                          
                              Title="News"
                              Icon="deck2.png"
                              x:Name="HomeContent"/>
            </ShellSection>        
            <ShellSection Title="Contact" Icon="contact.png" Route="contact" x:Name="ContactTab">
                <ShellContent Route="contact"                          
                              Title="Contact"
                              Icon="contact.png"
                              x:Name="ContactContent"/>
            </ShellSection>
            <ShellSection Title="Login" Icon="login.png" Route="login" x:Name="LoginTab">
                <ShellContent Route="login"                          
                              Title="Login"
                              Icon="login.png"
                              x:Name="LoginContent"/>
            </ShellSection>
        </ShellItem>


    </Shell>

In my xml pages I event set the Shell.FlyoutBehavior="Disabled" to see if it get's fixed and nothing what could be causing this problem

Answers

  • LandLuLandLu Member, Xamarin Team Xamurai

    ShellItem will create a side menu for you. Try to set its title and icon like:

    <ShellItem Style="{StaticResource BaseStyle}" Title="Item" Icon="item.png">
        ...
    <ShellItem/>
    

    You will see this item on the side menu and the hamburger is used for opening it.
    If you don't want this flyout style you can use Tabs directly: https://docs.microsoft.com/en-us/xamarin/xamarin-forms/app-fundamentals/shell/tabs
    And change the architecture to:

    <TabBar Style="{StaticResource BaseStyle}" >
        <ShellContent Route="index"
                            Title="Home"
                            Icon="home.png"
                            x:Name="IndexContent" />
    
        <!-- ... -->
    </TabBar>
    
Sign In or Register to comment.