简体   繁体   English

为什么使用 Xamarin 的 iOS 显示器上没有显示工具栏

[英]Why Toolbar not showing on iOS display using Xamarin

I want to display very simple Toolbar using xamarin on iOS, but I can't see the toolbar on display.我想在 iOS 上使用 xamarin 显示非常简单的工具栏,但我看不到显示的工具栏。

I use this code:我使用这段代码:

    <?xml version="1.0" encoding="utf-8" ?>
      <ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
                   xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
                   x:Class="Test.MainPage">

        <ContentPage.ToolbarItems>
          <ToolbarItem Text="Example Item"
                       IconImageSource="https://img.icons8.com/cute-clipart/64/000000/menu.png"
                     Order="Primary"
                     Priority="0" />
        </ContentPage.ToolbarItems>

</ContentPage>

There are no errors in the code and the display is empty..代码没有错误,显示为空..

What needs to change to see the toolbar?需要更改什么才能看到工具栏?

Are you putting your page in NavigationPage?您是否将页面放在 NavigationPage 中? By default ContentPage does not have Navigation bar (Toolbar), you must put your page in NavigationPage, after that Navigation bar will show up with its functionality.默认情况下 ContentPage 没有导航栏(工具栏),您必须将页面放在 NavigationPage 中,然后导航栏将显示其功能。 have a look at here: Xamarin.Forms Navigation看看这里: Xamarin.Forms

So I assume you should do something like this所以我认为你应该做这样的事情

public App ()
{
   MainPage = new NavigationPage (new MainPage());
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM