ToolbarItems do not look right in iOS

六月ゝ 毕业季﹏ 提交于 2020-04-30 06:27:27

问题


I have a Xamarin.Forms app with FreshMvvm, and am trying to use secondary ToolbarItems. Here is a part of my PageModel code:

  public override void Init(object initData)
  {
      CurrentPage.ToolbarItems.Add(new ToolbarItem() { Text = "About LATICRETE", Command = AboutCommand, Priority = 0, Order = ToolbarItemOrder.Secondary });
      CurrentPage.ToolbarItems.Add(new ToolbarItem() { Text = "Call LATICRETE", Command = CallCommand, Priority = 0, Order = ToolbarItemOrder.Secondary });
      CurrentPage.ToolbarItems.Add(new ToolbarItem() { Text = "Email Technical Support", Command = EmailTechSupportCommand, Priority = 0, Order = ToolbarItemOrder.Secondary });
      CurrentPage.ToolbarItems.Add(new ToolbarItem() { Text = "Visit LATICRETE Website", Command = VisitWebsiteCommand, Priority = 0, Order = ToolbarItemOrder.Secondary });

For Android, after pressing the hamburger button, the menu looks like I expect:

But at iPhone, it is quite different:

As you can see, there is no hamburger button, and all the ToolbarItems are placed horizontally next to each other, and as they do not fit withing the width of the screen, they overlap. I realize that this is the normal behavior for iOS, and yet it is not acceptable for me. Is there any way to fix it?


回答1:


On iOS, the Secondary items menu appears below the navigation bar as a horizontal list.

if you want to acheve the effect like in Android,you could create a custom PageRenderer.

here is a sample,you could refer to it iOSSecondaryToolbarMenubar

the effect in Android :

the effect in ios (you could change the icon in your renderer):

1) the first page has the toolbar items:

2) all pages have the toolbar items:



来源:https://stackoverflow.com/questions/59579949/toolbaritems-do-not-look-right-in-ios

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!