question

Jon-5102 avatar image
0 Votes"
Jon-5102 asked ColeXia-MSFT commented

Way to override the tabbar more menu

I was wondering how I would go about changing the "more" menu on a tabbar on iOS to be a bottom pop up rather than a full page.

dotnet-xamarin
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

ColeXia-MSFT avatar image
0 Votes"
ColeXia-MSFT answered ColeXia-MSFT commented

Hello,

Welcome to Microsoft Q&A!

If I understand correctly , do you want to show a pop up rather than a full page when clicking on the more button on tabbar ?

If so , you can achieve it with custom renderer in iOS project .

[assembly: ExportRenderer(typeof(TabbedPage), typeof(MyTabRenderer))]
namespace FormsA.iOS
{
    public class MyTabRenderer : TabbedRenderer
    {
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();
            this.ViewControllerSelected += MyTabRenderer_ViewControllerSelected;
 
        }

        UIViewController lastViewController;

        private void MyTabRenderer_ViewControllerSelected(object sender, UITabBarSelectionEventArgs e)
        {
            var index = this.ViewControllers.ToList().IndexOf(e.ViewController);

            if(index == -1)
            {
                //handle stuffs

                this.SelectedViewController = (lastViewController!=null)? lastViewController: this.ViewControllers[0];
            }

            lastViewController = e.ViewController;
        }
    }
}


Update



If you're using shell project ,check the code below

[assembly: ExportRenderer(typeof(Xaminals.AppShell), typeof(Xaminals.iOS.MyShellRenderer))]
namespace Xaminals.iOS
{
    public class MyShellRenderer : ShellRenderer
    {
        protected override IShellTabBarAppearanceTracker CreateTabBarAppearanceTracker()
        {
            return new TabBarAppearance();
        }
    }

    public class TabBarAppearance : IShellTabBarAppearanceTracker
    {
        public void Dispose()
        {

        }

        public void ResetAppearance(UITabBarController controller)
        {
            
        }

        bool isFirst = true;
        UIViewController lastViewController;
        public void SetAppearance(UITabBarController controller, ShellAppearance appearance)
        {

            if(isFirst)
            {
                controller.ViewControllerSelected += (sender, e) =>
                {
                    var index = controller.ViewControllers.ToList().IndexOf(e.ViewController);

                    if (index == -1)
                    {
                        //handle stuffs
                        controller.SelectedViewController = (lastViewController != null) ? lastViewController : controller.ViewControllers[0];
                    }
                    else
                    {
                        lastViewController = e.ViewController;
                    }             
                };
                isFirst = false;
            }         
        }

        public void UpdateLayout(UITabBarController controller)
        {
           
        }
    }
}


If the response is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

· 3
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Thanks! I'm sorry, I'm still really new to Xamarin Forms. So currently I'm implementing the Tabbar via <Shell><TabBar><ShellContent> this doesn't seem to be overriding the tabbar on iOS (v14.4). I noticed you inherited from TabbedRenderer, will this need to be a new page that i implement into shell tabbar??

0 Votes 0 ·

Am I missing something? I integrated this into the iOS project but the more button now does nothing.

0 Votes 0 ·

it , it does nothing , place you own logic into

if (index == -1)
                    {
                        //handle stuffs
                        controller.SelectedViewController = (lastViewController != null) ? lastViewController : controller.ViewControllers[0];
                    }
0 Votes 0 ·