嵌套presentViewController后,如何直接返回到最开始的那个viewcontroller?

3个viewcontroller: A, B, C

[A presentViewController: B animated: YES]
[B presentViewController: C animated: YES]

在C中如何直接返回到A,当前我得做法:
[c.presentingViewController.presentingViewController dismissViewControllerAnimated:YES completion:nil];
模拟器上测试,可以直接返回到A,但还是能够看到C返回到B, B再返回到A,只不过B停留在屏幕的时间非常的短。

我尝试过, [c.presentingViewController.presentingViewController dismissViewControllerAnimated:NO completion:nil];
会有闪的突兀感。觉得不好。

有什么方法,可以避免出现以上这种情况,使用户感觉不到B曾经出现过,同时也不会让用户感觉到屏幕顿闪的突兀感?

阅读 15.6k
2 个回答

presentingViewController连续嵌套不会觉得很奇怪?
我都是用navigation然后push,回到第一个只需要用self.navigationController popToRootViewControllerAnimated:
或者试试[[[[[self parentViewController] parentViewController] parentViewController] parentViewController] dismissModalViewControllerAnimated:YES];

新手上路,请多包涵

请问你是怎么解决的呢?我现在也遇到了这个问题

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题