UINavigationController到UIViewController的难度

时间:2012-07-03 09:30:22

标签: objective-c uiviewcontroller uinavigationcontroller

如何为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];

3 个答案:

答案 0 :(得分:1)

如果您有ViewController A,它提供了呈现ViewController C的ViewController B

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

[self dismissModalViewControllerAnimated:NO];
[[self presentingViewController] dismissModalViewControllerAnimated:NO];

答案 1 :(得分:0)

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

for(UIView *view in [self.view subviews])

答案 2 :(得分:0)

从上面的评论中我觉得你呈现的控制器如从A到B和从B到C。

现在你想要从C到A来做那个使用下面的代码

[self.navigationController popToRootViewControllerAnimated:YES];

修改

//Try this.
[[[self parentViewController] parentViewController] dismissModalViewControllerAnimated:YES];