Skip to content

Instantly share code, notes, and snippets.

@yetanotherchris
Last active December 13, 2015 19:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save yetanotherchris/4959948 to your computer and use it in GitHub Desktop.
Save yetanotherchris/4959948 to your computer and use it in GitHub Desktop.
Monotouch: ViewDidLoad, ViewWillAppear, ViewDidAppear
public class Level2ViewController : UIViewController
{
public override void ViewDidLoad()
{
Title = "Level 2";
UILabel label = new UILabel();
label.Text = "Level2ViewController";
label.Frame = new System.Drawing.RectangleF(100, 100, 100, 100);
View.AddSubview(label);
// A new toolbar with items
UIBarButtonItem item = new UIBarButtonItem();
item.Title = "Another item";
item.Clicked += delegate(object sender, EventArgs e)
{
Level3ViewController controller = new Level3ViewController();
NavigationController.PushViewController(controller, true);
};
ToolbarItems = new UIBarButtonItem[] { item };
base.ViewDidLoad();
}
public override void ViewWillAppear(bool animated)
{
// Re-show the toolbar here for consistency
NavigationController.SetToolbarHidden(false, true);
base.ViewWillAppear(animated);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment