Xamarin表单MasterDetailPage菜单图标未在iOS上显示 [英] Xamarin forms MasterDetailPage Menu icon not shown on iOS

查看:63
本文介绍了Xamarin表单MasterDetailPage菜单图标未在iOS上显示的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有Xamarin.Forms项目.我在NavigationPage中有MasterDetailPage.我设置了MasterDetailPage的icon属性,以便应将图标设置为导航栏的左上位置.但这是行不通的.

I have Xamarin.Forms project. I have MasterDetailPage inside NavigationPage. I set icon property of the MasterDetailPage so that icon is supposed to be set as the top left position on the navigation bar. But it does not work.

public partial class App : Application
{
    public App()
    {
        InitializeComponent();

        var masterDetailpage = new MasterDetailPage {
            Icon = "menuIcon.png",
            Master = new Page { Title = "Sample"},
            Detail = new Page()
        };

        MainPage = new NavigationPage(masterDetailpage);
    }
}

这永远都行不通.如果我将NavigationPage作为MasterDetailPage的Detail属性,并在Master上设置图标.有用.但是将MasterDetailPage放在NavigationPage内而不是Vise十分重要.

This never works. If I put NavigationPage as MasterDetailPage's Detail property, and set icon on the Master. It works. But it is very important to have MasterDetailPage inside NavigationPage and not vise versa.

推荐答案

解决方案是设置用于 Master的 Page Icon 属性.

The solution is to set the Icon property of the Page being used for the Master.

 var masterDetailpage = new MasterDetailPage {            
        Master = new Page { Title = "Sample", Icon = "menuIcon.png"},
        Detail = new NavigationPage(new Page())
    };

这假设您的iOS项目中的资源文件夹下名为 menuIcon.png 的png是您想要的汉堡包图标.您还需要在 Detail 周围使用 NavigationPage ,因为 Icon 显示在导航栏区域.

This assumes you have a png in your iOS project under the Resources folder named menuIcon.png that is the hamburger icon you want. You will also need to use a NavigationPage around the Detail because the Icon is shown in the Navigation Bar area.

这篇关于Xamarin表单MasterDetailPage菜单图标未在iOS上显示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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