显示在sidemenu导航ios xamarin的导航栏

时间:2017-10-23 14:22:04

标签: c# ios iphone xamarin xamarin.ios

我在我的应用程序中使用了侧边栏导航xamarin组件,但导航栏显示在侧面菜单上,它不会随导航控制器一起滑动。

xamarin组件:https://components.xamarin.com/view/sidebarnavigation

这是我的代码。 公共AgentDetails代理{get;组; }         public SidebarController SidebarController {get;私人集; }

    public RootController (IntPtr handle) : base (handle)
    {
    }

    public override void ViewDidLoad()
    {
        base.ViewDidLoad();

    }

    public override void LoadView()
    {
        base.LoadView();
        UIImageView img = new UIImageView(new CGRect(0, 0, 120, 50));
        img.Image = UIImage.FromBundle("Logo.png");
        img.ContentMode = UIViewContentMode.ScaleAspectFit;
        this.NavigationItem.LeftBarButtonItem = new UIBarButtonItem(img);
        //this.NavigationItem.Title = true;

        //menuOpen.SetBackgroundImage(UIImage.FromBundle("Menu.png"), UIControlState.Normal);
        UIBarButtonItem back = new UIBarButtonItem();
        back.SetBackButtonBackgroundImage(UIImage.FromBundle("Back.png"), UIControlState.Normal, UIBarMetrics.Compact);
        this.NavigationItem.BackBarButtonItem = back;

        this.NavigationController.NavigationBar.BackgroundColor = UIColor.FromRGB(255, 0, 0);

        var storyboard = UIStoryboard.FromName("Main", null);
        MainTabController tab = storyboard.InstantiateViewController("TabPage") as MainTabController;
        SideMenuController side = storyboard.InstantiateViewController("SideMenu") as SideMenuController;
        side.rootController = this;
        tab.agent = agent;
        SidebarController = new SidebarController(this, tab, side);

        this.NavigationController.NavigationBar.Translucent = false;
        menuOpen.TouchUpInside += MenuOpen_TouchUpInside;
        LoadSchedule();
    }

    void LoadSchedule()
    {
        AgentAPI agentData = new AgentAPI();
        agentData.EmpId = agent.PortalId;
        agentData.ScheduleHours((schedule) =>
        {
            JObject jsondata = JsonConvert.DeserializeObject<JObject>(schedule);
            if (jsondata["status"].ToString() == "200")
            {
                agent.Schedule = JsonConvert.DeserializeObject<List<Schedule>>(jsondata["activity"].ToString());
            }
        });
    }

    private void MenuOpen_TouchUpInside(object sender, EventArgs e)
    {
        SidebarController.ToggleMenu();
    }

image of my sidemenu

1 个答案:

答案 0 :(得分:0)

不要将RootViewController嵌入NavigationController。 改为嵌入ContentController。

例如,RootViewController.cs中的代码段如下:

SidebarController = new SidebarController(this, new UINavigationController(new ContentController()), new SideMenuController());