ToolbarItems在iOS中看起来不正确 [英] ToolbarItems do not look right in iOS

查看:110
本文介绍了ToolbarItems在iOS中看起来不正确的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个带有FreshMvvm的Xamarin.Forms应用程序,并且正在尝试使用辅助ToolbarItems.这是我的PageModel代码的一部分:

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 });

对于Android,按下汉堡包按钮后,菜单看起来像我期望的那样:

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

但是在iPhone上却大不相同:

But at iPhone, it is quite different:

如您所见,没有汉堡按钮,并且所有ToolbarItem都水平并排放置,并且由于它们不适合屏幕宽度,因此它们会重叠.我意识到这是iOS的正常行为,但对我来说还是不可接受的.有什么办法可以解决?

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?

推荐答案

在iOS上,Secondary项目菜单作为水平列表显示在导航栏下方.

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

如果您想要达到与Android一样的效果,则可以创建自定义PageRenderer.

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

这是一个示例,您可以参考 iOSSecondaryToolbarMenubar

here is a sample,you could refer to it iOSSecondaryToolbarMenubar

在Android中的效果:

the effect in Android :

ios中的效果(您可以在渲染器中更改图标):

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

1)第一页包含工具栏项:

1) the first page has the toolbar items:

2)所有页面都有工具栏项:

2) all pages have the toolbar items:

这篇关于ToolbarItems在iOS中看起来不正确的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆