I'm trying to create a custom back button, and everything seems to work except the Clicked event.
I have 2 screens that I am going between. We will call them Screen1 and Screen2. There is a button in Screen1 that takes me to Screen2 when clicked.
The following code is how I'm attempting to create a custom back, which has been placed in both ViewDidLoad and ViewWillDisappear of Screen1 (the following is what I have in ViewWillDisappear). The code used in both functions are the last two lines in the following code.
protected override void ViewWillDisappear(bool animated) {
base.ViewWillDisappear(animated);
this.NavigationController.SetNavigationBarHidden(false, animated);
UIBarButtonItem backBtn = new UIBarButtonItem("NewTitle", UIBarButtonItemStyle.Plain, delegate { Console.WriteLine("clicked"); });
this.NavigationItem.BackBarButtonItem = backBtn;
}
When running, the word "clicked" never appears in the console when I click the back button in Screen2. I've also tried hiding the default by calling
this.NavigationItem.SetHidesBackButton(true, false);
before creating the button, but it didn't affect anything.
Any advice will be greatly appreciated!