2016-04-13 78 views
0

在我的项目中,我有2个故事板。一个用于登录,另一个用于主要。 登录完成后我目前使用这种方法的主要情节提要:关闭其他故事板

-(void)successLogin { 
    UIStoryboard *mainStoryboard = [UIStoryboard storyboardWithName:@"Main" bundle:nil]; 
    UIViewController *vc = [mainStoryboard instantiateInitialViewController]; 
    [self presentViewController:vc animated:YES completion:nil]; 
} 

我的问题是如何获取到登陆故事板,如果我想提出注销按钮,在主要故事板。我试图做以下几点:

[self dismissViewControllerAnimated:YES completion:nil]; 

而且它仍然不起作用。

+1

为什么你不把你的登陆VC主stroyboard?指一个故事板中的所有内容。您应该为每个VC使用一个故事板,并使用导航控制器来推送和弹出视图。 – Lion

+1

在你的情况下使用多个Storyboard是没有意义的。只使用单个故事板。 – Raptor

回答

0

试穿这个LOGOUT单击事件:

UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Main" bundle:nil]; 

LoginviewController *Login = [storyboard instantiateViewControllerWithIdentifier:@"LoginviewController"]; 

[self.navigationController pushViewController:Login animated:YES]; 
0

尝试设置一个视图控制器作为根视图控制器然后呈现另一个视图控制器。

[[[UIApplication sharedApplication] keyWindow] setRootViewController:viewController]; 

[viewController presentViewController:VC animated:YES completion:nil]; 

你会来RootViewController的,当你dismissViewControllerAnimated:

0

注销成功 试试这个代码,它为你工作

-(void)successlogout 
{ 
    //[self dismissViewControllerAnimated:NO completion:nil]; 
    UIStoryboard *mainStoryboard = [UIStoryboard storyboardWithName:@"Main" bundle:nil]; 
    login *vc = [mainStoryboard instantiateViewControllerWithIdentifier:@"login"]; 
    [self presentViewController:vc animated:NO completion:nil]; 

}