public void ChangeViewController(ViewTag tag) { // Does the switch between the diferents views switch (tag) { case ViewTag.ScanView: // If it's the first time being called, created it and assign it if (scanNC == null) { var scanVC = ScanBuyVC.Storyboard.InstantiateViewController("ScanViewControllerID") as ScanViewController; scanVC.NavigationItem.LeftBarButtonItem = btnMenu; scanNC = new UINavigationController(scanVC); } ScanBuyVC.TopViewController = scanNC; break; case ViewTag.RecordView: if (recordNC == null) { var recordVC = ScanBuyVC.Storyboard.InstantiateViewController("RecordViewControllerID") as RecordViewController; recordVC.NavigationItem.LeftBarButtonItem = btnMenu; recordNC = new UINavigationController(recordVC); } ScanBuyVC.TopViewController = recordNC; break; default: break; } ScanBuyVC.ResetTopView(true); }
public override bool FinishedLaunching(UIApplication application, NSDictionary launchOptions) { // Gets the first view controller that is created, the base of the app if (Window.RootViewController is ScanBuyViewController) { ScanBuyVC = Window.RootViewController as ScanBuyViewController; } else { throw new Exception("The RootViewController is not a ScanViewController class"); } CreateDatabase(); // Creates the button that shows the menu btnMenu = new UIBarButtonItem(UIImage.FromFile("menu.png"), UIBarButtonItemStyle.Plain, (sender, e) => { ScanBuyVC.AnchorTopViewToRight(true); }); // Create and configure the first view, with his navigation, that will be shown var scanVC = ScanBuyVC.Storyboard.InstantiateViewController("ScanViewControllerID") as UIViewController; scanVC.NavigationItem.LeftBarButtonItem = btnMenu; scanNC = new UINavigationController(scanVC); // Sets the first view that will be shown ScanBuyVC.TopViewController = scanNC; // Set the menu to the left of the main view controller var leftVC = ScanBuyVC.Storyboard.InstantiateViewController("MenuViewControllerID") as MenuViewController; ScanBuyVC.UnderLeftViewController = leftVC; ScanBuyVC.AnchorLeftRevealAmount = 200f; ScanBuyVC.View.AddGestureRecognizer(ScanBuyVC.PanGesture); return(true); }