解雇其他故事板

时间:2016-04-13 08:11:42

标签: ios objective-c xcode uinavigationcontroller storyboard

在我的项目中,我有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];

它仍然不起作用。

3 个答案:

答案 0 :(得分:0)

在LOGOUT点击事件上试试这个:

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

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

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

答案 1 :(得分:0)

尝试将一个视图控制器设置为根视图控制器,然后显示另一个视图控制器。

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

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

当你 dismissViewControllerAnimated:

时,你会来到rootViewController

答案 2 :(得分: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];

}