英文:
ToolbarItems do not look right in iOS
问题
以下是翻译好的部分:
我有一个使用FreshMvvm的Xamarin.Forms应用程序,并尝试使用辅助工具栏项。这是我的PageModel代码的一部分:
public override void Init(object initData)
{
CurrentPage.ToolbarItems.Add(new ToolbarItem() { Text = "关于LATICRETE", Command = AboutCommand, Priority = 0, Order = ToolbarItemOrder.Secondary });
CurrentPage.ToolbarItems.Add(new ToolbarItem() { Text = "呼叫LATICRETE", Command = CallCommand, Priority = 0, Order = ToolbarItemOrder.Secondary });
CurrentPage.ToolbarItems.Add(new ToolbarItem() { Text = "电子邮件技术支持", Command = EmailTechSupportCommand, Priority = 0, Order = ToolbarItemOrder.Secondary });
CurrentPage.ToolbarItems.Add(new ToolbarItem() { Text = "访问LATICRETE网站", Command = VisitWebsiteCommand, Priority = 0, Order = ToolbarItemOrder.Secondary });
}
对于Android,在按下汉堡按钮后,菜单看起来像我期望的那样:
但在iPhone上,情况大不相同:
正如您所看到的,没有汉堡按钮,并且所有的ToolbarItems都水平放置在一起,由于它们不适合屏幕的宽度,它们重叠在一起。我意识到这是iOS的正常行为,但对我来说是不可接受的。是否有任何方法可以修复它?
英文:
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
得分: 3
在iOS上,“Secondary”项目菜单会出现在导航栏下方,呈水平列表形式。
如果您想要实现类似Android中的效果,您可以创建一个自定义的“PageRenderer”。
这里有一个示例,您可以参考这个链接:iOSSecondaryToolbarMenubar
在Android中的效果:
在iOS中的效果(您可以在自定义的渲染器中更改图标):
1)第一页具有工具栏项目:
2)所有页面都具有工具栏项目:
英文:
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):
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论