我是這個領域的新手。我正在開發一個應用程序,用戶可以從應用程序中的任何頁面註銷。從iOS註銷App
我正在使用此方法進行註銷過程。 (從What is the perfect way to make a logout from IOS app?簡稱)
- (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex {
if (buttonIndex == 0) {
NSUserDefaults * defaults = [NSUserDefaults standardUserDefaults];
[defaults setObject:nil forKey:@"UserId"];
[defaults synchronize];
//redirect to login view
NewClassMoonAppDelegate * appsDelegate =[[UIApplication sharedApplication] delegate];
LoginViewController *second = [[LoginViewController alloc]initWithNibName:nil bundle:nil];
[appsDelegate.window setRootViewController:nil];
[appsDelegate.window setRootViewController:login];
}
}
我的問題是如何進行註銷之前關閉所有打開的ViewController?當我執行上面的方法時,我點擊了註銷按鈕的頁面在後臺保持打開狀態。任何人都可以幫助我。提前致謝。
註銷成功後,您應該執行「關閉」堆棧中的所有VC。只需調用'[self.navigationController popToRootViewControllerAnimated:YES];'。這將彈出導航堆棧中所有現有的VC並將您帶回根目錄Vc – NSNoob
viewcontroller停留在後臺?你是什麼意思。它仍然可見嗎? – MarkHim
謝謝@ NSNoob .. Bt這個應用程序不使用導航控制器。有沒有其他的方式.. ?? – luckyShubhra