简体   繁体   English

无法在TabController内的NavigatioNController中的Xamarin iOS中添加导航项

[英]Can't Add Navigation Item in Xamarin iOS in NavigatioNController inside TabController

I'm trying to add a NavigationItem to my Navbar put when I deploy it on my device it will not show up. 我正在尝试向我的Navbar添加一个NavigationItem,当我在我的设备上部署它时它不会显示。

I think it's similar to the tutorial on the xamarin website. 我认为它类似于xamarin网站上的教程。

Any ideas? 有任何想法吗?

This is my code: 这是我的代码:

using System;
using UIKit;

namespace myNameSpace
{
    public class LinksPageController : UINavigationController
    {
        public LinksPageController ()
        {
            NavigationBar.BarTintColor = UIColor.FromRGB (183, 28, 28);
        }

        public override void ViewDidLoad ()
        {
            base.ViewDidLoad ();
            this.NavigationItem.SetRightBarButtonItem(
                new UIBarButtonItem(UIBarButtonSystemItem.Action, (sender,args) => {
                    UIAlertView alert = new UIAlertView("Add link!", "Enter the ID of the person you want to be linked with:", null, "Cancel", "OK");
                    alert.AlertViewStyle = UIAlertViewStyle.PlainTextInput;
                    alert.Show ();
                })
                , true);
        }

        public override void ViewWillAppear (bool animated)
        {
            base.ViewWillAppear (animated);
        }
    }
}

How about instantiating a class button before adding it to the navBar? 如何在将类按钮添加到navBar之前实例化它? could it be that you are losing the instance pointer..?? 可能是你正在丢失实例指针.. ??

UIBarButtonItem * newButton;
public override void ViewDidLoad ()
    {
        base.ViewDidLoad ();

        newButton =  new UIBarButtonItem(UIBarButtonSystemItem.Action, (sender,args) => {
                UIAlertView alert = new UIAlertView("Add link!", "Enter the ID of the person you want to be linked with:", null, "Cancel", "OK");
                alert.AlertViewStyle = UIAlertViewStyle.PlainTextInput;
                alert.Show ();
            })

        this.NavigationItem.SetRightBarButtonItem(newButton, true);
    }

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

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