public override void OnResignActivation(UIApplication application) { UIStoryboard story = UIStoryboard.FromName("Main", NSBundle.MainBundle); VaultInstructionsController vaultInstructions = story.InstantiateViewController("VaultInstructionsController") as VaultInstructionsController; if (this.navMaster.VisibleViewController == vaultInstructions) { vaultInstructions.DismissViewController(true, null); } SystemSound soundLock = new SystemSound(1100); soundLock.PlaySystemSound(); var memoryCache = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments); var filePathPassword = System.IO.Path.Combine(memoryCache, "password.txt"); try { if (filePathPassword == null) { throw new FileNotFoundException(); } else { if (String.IsNullOrEmpty(File.ReadAllText(filePathPassword)) == true) { if (this.navMaster.VisibleViewController != this.passwordFirstControl) { this.navMaster.PopToViewController(this.passwordFirstControl, true); } else { Console.WriteLine("Controller already exists"); } } else { if (this.navMaster.ViewControllers.Contains(this.password) == true) { if (this.navMaster.VisibleViewController != this.password) { this.passwordLog.Text = ""; this.passwordLog.ResignFirstResponder(); this.navMaster.PopToViewController(this.password, true); } else { Console.WriteLine("Controller already exists"); } } else { this.navMaster.PushViewController(this.password, true); } } } } catch (FileNotFoundException) { if (this.navMaster.VisibleViewController != this.passwordFirstControl) { this.navMaster.PushViewController(this.passwordFirstControl, true); } else { Console.WriteLine("Controller already exists"); } } }