0

我有一个使用故事板的应用程序。布局是:导航控制器 > 登录视图控制器 > 选项卡栏控制器,每个选项卡都有一个导航控制器,指向该选项卡的 UIViewController。我正在尝试创建一个注销按钮,该按钮将删除 TabBarController 并返回到登录视图控制器。我的代码如下:

// In log out function
[self.tabBarController dismissViewControllerAnimated:YES completion:nil];
[self performSelector:@selector(patchSelector) withObject:nil afterDelay:0.3];

-(void)patchSelector{
    [self.tabBarController.navigationController popToRootViewControllerAnimated:YES];
}

我不断收到以下错误:

*** Terminating app due to uncaught exception 'UIViewControllerHierarchyInconsistency', reason: 'presentedViewController for controller is itself on dismiss for

我尝试阅读以下内容:

没有可见的dismissModalViewControllerAnimated界面:完成

http://www.touchthatfruit.com/viewwillappear-and-viewdidappear-not-being-ca

UITabbarController 关闭模式 UINavigationController

但是,以上都没有帮助解决我遇到的错误。我在这有什么遗漏吗?该错误似乎表明当前的 vc 正在清理中。

4

1 回答 1

0

[self dismissModalViewControllerAnimated:YES];当我删除我的第一个UINavigationController (登录屏幕之前的那个)并将上面的第一行更改为此:最简单的解决方案。不知道为什么我原来的问题是,但我至少能够以这种方式解决它!

于 2012-12-30T22:01:08.843 回答