iOS : ToolbarItems not displaying on root navigation page

Umar3xUmar3x FRMember ✭✭✭

Hello all,

I got three toolbaritems in my app which display everywhere on Android.
Prob is on iOS it only shows on pages which are pushed in the navigationPage. When I'm on the root page of the navigation page, they don't display. How to force iOS to show them even if I'm on the root of the navigationPage ?

Thanks.

     var toolbarItem = new ToolbarItem
            {
                Order = ToolbarItemOrder.Secondary,
                Priority = 0,
                Text = "Help"
            };
            var toolbarItem2 = new ToolbarItem
            {
                Order = ToolbarItemOrder.Secondary,
                Priority = 1,
                Text = "Support"
            };
            var homeToolBar = new ToolbarItem
            {
                Order = ToolbarItemOrder.Primary,
                Priority = 0,
                Icon = "ic_home_black_18dp"
            };

Best Answer

  • Umar3xUmar3x FR ✭✭✭
    Accepted Answer

    @divyagarimella
    I can't remember exactly why I had this issue (1 year now) but I got everything working with this, hope that will help you :

             var toolbarItem = new ToolbarItem
                {
                    Order = Device.RuntimePlatform == Device.iOS ? ToolbarItemOrder.Primary : ToolbarItemOrder.Secondary,
                    Priority = 1,
                    Text = Device.RuntimePlatform == Device.iOS ? null : "Help",
                    Icon = Device.RuntimePlatform == Device.iOS ? "ic_help_outline_black_18dp" : null,
                };
                var toolbarItem2 = new ToolbarItem
                {
                    Order = Device.RuntimePlatform == Device.iOS ? ToolbarItemOrder.Default : ToolbarItemOrder.Secondary,
                    Priority = 1,
                    Text = Device.RuntimePlatform == Device.iOS ? null : "Support",
                    Icon = Device.RuntimePlatform == Device.iOS ? "ic_email_black_18dp" : null,
    
                };
    
                navigationPage.ToolbarItems.Add(toolbarItem);
                navigationPage.ToolbarItems.Add(toolbarItem2);
    

Answers

  • ShantimohanElchuriShantimohanElchuri USMember ✭✭✭✭✭

    @Umar3x Change the forground color of the icon and see. At least that was problem I had.

  • Umar3xUmar3x FRMember ✭✭✭
    edited February 2018

    The foreground color of the icon ? What do you mean exactly ? You mean changing icon color, or its background. Furthemore, I have no Icon for toolbarItem and toolbarItem 2 in the snippet I posted, still not displaying ... Thanks.

  • Umar3xUmar3x FRMember ✭✭✭

    Anyway got an idea ... ? I'm still not finding why on the root page of the navigation page on iOS only toolbaritems do not display.

    My main page is a MasterPageDetails with a navigation page (wrapping a mapPage) as detailsPage of master.

    Thanks.

  • divyagarimelladivyagarimella Member ✭✭

    hi
    Any luck on this.i am having the same problem.please post it here if you have any solution

  • Umar3xUmar3x FRMember ✭✭✭
    Accepted Answer

    @divyagarimella
    I can't remember exactly why I had this issue (1 year now) but I got everything working with this, hope that will help you :

             var toolbarItem = new ToolbarItem
                {
                    Order = Device.RuntimePlatform == Device.iOS ? ToolbarItemOrder.Primary : ToolbarItemOrder.Secondary,
                    Priority = 1,
                    Text = Device.RuntimePlatform == Device.iOS ? null : "Help",
                    Icon = Device.RuntimePlatform == Device.iOS ? "ic_help_outline_black_18dp" : null,
                };
                var toolbarItem2 = new ToolbarItem
                {
                    Order = Device.RuntimePlatform == Device.iOS ? ToolbarItemOrder.Default : ToolbarItemOrder.Secondary,
                    Priority = 1,
                    Text = Device.RuntimePlatform == Device.iOS ? null : "Support",
                    Icon = Device.RuntimePlatform == Device.iOS ? "ic_email_black_18dp" : null,
    
                };
    
                navigationPage.ToolbarItems.Add(toolbarItem);
                navigationPage.ToolbarItems.Add(toolbarItem2);
    
  • divyagarimelladivyagarimella Member ✭✭

    Hi umar,thank you for your response
    where you have placed your images,my images are in Resources folder and my images are png icons

  • Umar3xUmar3x FRMember ✭✭✭

    @divyagarimella

    Well, I'm not sure I understood your question but :

    • On android you have to place each images for the corresponding size in the Resources/drawable-SIZE folder.
    • On iOS I am using the asset catalog (good practise though, instead of putting everything at the root of the Resources folder)

    If you need more info about how to use images on XF => https://docs.microsoft.com/en-us/xamarin/xamarin-forms/user-interface/images?tabs=windows

Sign In or Register to comment.