I'm trying to add a NavigationItem to my Navbar put when I deploy it on my device it will not show up.
I think it's similar to the tutorial on the xamarin website.
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? 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);
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.