public bool LogOut() { int buttonClicked = -1; UIAlertView alert1 = new UIAlertView(@"Alert", @"Are you sure you want to log out?", null, NSBundle.MainBundle.LocalizedString("Cancel", "Cancel"), NSBundle.MainBundle.LocalizedString("OK", "OK")); alert1.Show(); alert1.Clicked += (sender, buttonArgs) => { buttonClicked = (int)buttonArgs.ButtonIndex; }; // Wait for a button press. while (buttonClicked == -1) { NSRunLoop.Current.RunUntil(NSDate.FromTimeIntervalSinceNow(0.5)); } if (buttonClicked == 1) { AppDelegate.deleteSession(); ClearMemory(); AppDelegate.stopAutoSync(); LoginViewController loginViewController = this.Storyboard.InstantiateViewController("LoginViewController") as LoginViewController; this.NavigationController.PushViewController(loginViewController, false); return(true); } return(false); }
public void ClearMemory() { UIStoryboard storyboard = Window.RootViewController.Storyboard; UINavigationController navController = (UINavigationController)Window.RootViewController; if (navController != null && navController.ViewControllers != null && navController.ViewControllers.Count() > 0) { List <UIViewController> viewcontrollers = new List <UIViewController> (); viewcontrollers = navController.ViewControllers.ToList(); viewcontrollers.RemoveAll(i => i is UIViewController); navController.ViewControllers = viewcontrollers.ToArray(); LoginViewController loginViewController = storyboard.InstantiateViewController("LoginViewController") as LoginViewController; navController.PushViewController(loginViewController, false); } }
partial void btn_Logout_TouchUpInside(UIButton sender) { UIAlertView alert1 = new UIAlertView(@"Alert", @"Are you sure you want to log out?", null, NSBundle.MainBundle.LocalizedString("Cancel", "Cancel"), NSBundle.MainBundle.LocalizedString("OK", "OK")); alert1.Show(); int buttonClicked = -1; alert1.Clicked += (sender1, buttonArgs) => { buttonClicked = (int)buttonArgs.ButtonIndex; if (buttonClicked == 1) { LoginViewController loginViewController = this.Storyboard.InstantiateViewController("LoginViewController") as LoginViewController; this.NavigationController.PushViewController(loginViewController, false); } }; }
public LoginTextFieldDelegate(LoginViewController loginController) { this.loginController = loginController; }