ios - presentViewController和pushViewController跳转页面之后,如何回到最初的页面?
黄舟
黄舟 2017-04-17 17:10:06
0
3
645

A页面跳到B页面。用模态切换presentViewController的方式跳转

UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:VC];
    [self presentViewController:nav animated:YES completion:nil];

这样跳到了B页面。B又跳到了C页面。C又跳到D页面。

用导航控制器入栈的方式切换,代码如下:

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

现在问题来了。我要从D页面。直接回到A页面。应该怎么回?


好像这样解决了

[((UIViewController*)weakSelf.navigationController.viewControllers[0]) dismissViewControllerAnimated:YES completion:^{
                    [[NSNotificationCenter defaultCenter] postNotificationName:NotificationLoginCallBack object:nil];
                }];

只是还不算完美。首先切到了B页面,然后B消失,回到了A页面。
如果能从D直接动画切到A。不经过B页面,更完美。不过目前算可用了
希望有更完美的方案

黄舟
黄舟

人生最曼妙的风景,竟是内心的淡定与从容!

reply all(3)
黄舟

I didn’t have time yesterday so I took a seat and answered it casually. After testing it today, the conclusion is:

Directly call the dismissViewControllerAnimated method of self.navigationController.
The animation effect is directly pushed downwards.

迷茫

for (UIViewController *temp in self.navigationController.viewControllers) {

    if ([temp isKindOfClass:[AviewController class]]) {
        [self.navigationController popToViewController:temp animated:YES];
    }
}
洪涛

Blogger, I am also working on such a function. Did you finally solve this problem?

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template