如何显示login和解除设置 – 故事板

我想弄清楚如何显示login(模式viewcontroller)从注销button和自动解雇设置(模态viewcontroller)从下面的login。 您可能会看到故事板布局:

scrshot.png

我试图将这个代码添加到SettingsViewController.m中的注销方法

- (IBAction)logoutAccount { [self dismissModalViewControllerAnimated:YES]; UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"MainStoryboard" bundle:nil]; UIViewController *vc = [storyboard instantiateViewControllerWithIdentifier:@"LoginViewController"]; [vc setModalPresentationStyle:UIModalPresentationFullScreen]; [self presentModalViewController:vc animated:YES]; } 

问题是它强制我的应用程序冻结,当我点击注销。 有人知道它有什么问题吗? 任何build议表示赞赏。

用户再次login后,您希望应用程序在哪里? 比方说,你想要的应用程序在设置button的视图控制器(它看起来像故事板的方式)。

然后,该vc(导航控制器中的根vc)可以这样做:

 - (void)viewDidAppear:(BOOL)animated { if (/*login is needed*/) { UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"MainStoryboard" bundle:nil]; UIViewController *vc = [storyboard instantiateViewControllerWithIdentifier:@"LoginViewController"]; [vc setModalPresentationStyle:UIModalPresentationFullScreen]; [self presentModalViewController:vc animated:YES]; } else { // normal view did appear logic } } 

注销button现在可以做到这一点:

 - (IBAction)logoutButtonPressed:(id)sender { [self.navigationController popToRootViewControllerAnimated:NO]; }