I have a monotouch project with a RootViewController that initiallay loads up the viewcontrollers :-
this.AddChildViewController( secondViewController );
this.AddChildViewController( firstViewController );
View.AddSubview( firstViewController.View );
firstViewController.DidMoveToParentViewController( this );
each viewController contains a toolbar whose buttons are added like:
loaderButton = new MonoTouch.UIKit.UIBarButtonItem( UIBarButtonSystemItem.Action, loaderClickHandler );
or
closeButton = new MonoTouch.UIKit.UIBarButtonItem( "Close", UIBarButtonItemStyle.Done, new EventHandler( closeClickHandler ) );
where loaderClickHandler is just:
private void loaderClickHandler( System.Object sender, System.EventArgs e )
{
System.Console.WriteLine( "loaderClickHandler()" );
}
This all works fine, (but please, let me know if there is a better way)
The problem comes with the secondViewController (which is basically the same as the first, just different text).
when it is switched to by the RootViewController with:
this.Transition( firstViewController, secondViewController, 0.2, UIViewAnimationOptions.TransitionCrossDissolve, () => { }, (bool finished) => { secondViewController.DidMoveToParentViewController( this ); } );
It displays fine but it’s toolbar buttons don’t call the event handler methods when clicked/touched ?
All variables(loaderButton) are class level.
Anybody know why ? or what I’m doing wrong ?
DOH !
It helps when you add the toolbar AFTER any other items !