0

如何将其转换为UIViewController可能:

for (UIViewController *tmpController  in [self.navigationController viewControllers]) 
{
    if ([tmpController isKindOfClass:[RootViewController class]])
    {
        [self.navigationController popToViewController:tmpController animated:YES];
        break;
    }
}

[self.navigationController viewControllers]--> 如何将其转换为UIViewController,因为我有错误,

[self.navigationController popToViewController:tmpController animated:YES];--> 虽然这部分我把它转换成这个 -->[self dismissModalViewControllerAnimated:YES];

4

3 回答 3

1

如果您有 ViewController A 呈现 ViewController B 呈现 ViewController C

而你想回到 A,在 viewController C 中执行以下操作

[self dismissModalViewControllerAnimated:NO];
[[self presentingViewController] dismissModalViewControllerAnimated:NO];
于 2012-07-03T09:53:32.713 回答
0

您可以按如下方式获取视图层次结构:

for(UIView *view in [self.view subviews])
于 2012-07-03T09:52:28.517 回答
0

从上面的评论中,我觉得您正在展示从 A 到 B 和从 B 到 C 之类的控制器。

现在你想从 C 到 A 使用以下代码来做到这一点

[self.navigationController popToRootViewControllerAnimated:YES];

编辑

//Try this.
[[[self parentViewController] parentViewController] dismissModalViewControllerAnimated:YES];
于 2012-07-03T09:53:01.217 回答