Your code cannot work because your view controller is not being managed by a 
navigation controller. Setting toolbar items on a controller that does not have 
a toolbar (like if it was pushed by a navigation controller) has no effect 
whatsoever. 

If it is handled by a navigation controller, try making the toolbar visible:
this.NavigationController.SetToolbarHidden(false, true);

Note that if you want to add a back button on the top of the screen, it is not 
the toolbar items you need, but the NavigationItem.

Dimitris Tavlikos
Software Developer
Email: [email protected]
Twitter: http://twitter.com/#!/dtavlikos
Blog: http://software.tavlikos.com






On Jun 13, 2011, at 11:36 PM, Wally McClure wrote:

> I wanted to add a back button on my view when I load it.  Unfortunately, I am 
> unable to get the back button to display.  I have the code below in my 
> ViewDidLoad() method.  Any suggestions are appreciated.
> 
>               public override void ViewDidLoad()
>               {
>                       // Do some other things
>                       var btn = new UIBarButtonItem ("Back", 
> UIBarButtonItemStyle.Plain, delegate (object sender, EventArgs e) {
>                             Console.WriteLine("BarButtonItem clicked.");
>                       });
>                       
>                       ToolbarItems = new UIBarButtonItem[] {btn};
>                       SetToolbarItems(ToolbarItems, true);
>                       base.ViewDidLoad();
>               }
> _______________________________________________
> MonoTouch mailing list
> [email protected]
> http://lists.ximian.com/mailman/listinfo/monotouch

_______________________________________________
MonoTouch mailing list
[email protected]
http://lists.ximian.com/mailman/listinfo/monotouch

Reply via email to