Ryan
Ryan

Reputation: 28187

Change "back" NavigationItem text in Monotouch?

Is it possible to change the "Back" button text in a NavigationItem? At present, the caption of the back button assumes the title of the previous layer in the navigation stack, which is expected.

However, the NavigationItem's LeftBarButtonItem can be changed using code such as this:

UIBarButtonItem backButton = new UIBarButtonItem("Back", UIBarButtonItemStyle.Plain, null);
myNewView.NavigationItem.SetLeftBarButtonItem(backButton, true);

This works and the back button is displayed as expected, but the button is a square and does not navigate back to the previous layer as expected. I'm guessing that the correct event needs to be assigned to it, but I have no idea what it should be.

How would one go about ensuring that the new UIBarButtonItem has the correct event and arrow shape?

Note: I have also tried re-using the `LeftBarButtonItem' as suggested in this SO question, but I still don't know how to customize the button caption. I am probably just missing the obvious.

Thanks!

Upvotes: 1

Views: 3642

Answers (1)

Steven Kramer
Steven Kramer

Reputation: 8513

Set the title on the previous viewcontrollers navigationitem. I answered this before and will look up the link.

Ah, yes: Separate title in NavigationBar and navigation buttons

Upvotes: 3

Related Questions