入栈顺序a -> b -> c  .相应的默认的出栈顺序为 c - > b -> a . 
如果想直接 c -> a 也能实现,但需要你做一些处理,首先默认的back操作就不能用了,需要你自己在控制器中通过设置leftbarbuttonitem 来模拟back,目的是为了实现自定义的出栈操作。 出栈默认使用的是popViewController: 这是回退到上个控制器,如果要回到指定的控制器,需要使用popToViewController: .这个方法需要你先得到要跳转的目的控制器的实例,这个实例,你可以通过self.navigationController.viewControllers 属性中根据索引来找。直接回退到a 不需要pushView:a 

解决方案 »

  1.   

    使用storyboard,,unwindseguehttp://www.cnblogs.com/ZJUT-jiangnan/p/3902638.html
      

  2.   

    直接setViewControllers就行了。
    类似于这样:[self.navigationController setViewControllers:viewControllers animated:YES];
    这是一种标准做法,就像iOS系统快速进入某个设置页面一样。
      

  3.   


    假如有这个情况呢     
    在a点击一个按你可以到c:a->c       
    或者a点击一个按钮到b,然后在b里面可以跳入到c:a->b->c      
    但是在c里面点击返回,只会跳回到a:c->a
    那么这样如果我是通过a->b->c然后 c->a  这样的话 poptoview 会不会有问题呢? 它能自动知道走哪条路回去么?
      

  4.   


    假如有这个情况呢     
    在a点击一个按你可以到c:a->c       
    或者a点击一个按钮到b,然后在b里面可以跳入到c:a->b->c      
    但是在c里面点击返回,只会跳回到a:c->a
    那么这样如果我是通过a->b->c然后 c->a  这样的话 poptoview 会不会有问题呢? 它能自动知道走哪条路回去么?
    只要取决于你入栈的顺序,要了解栈这种数据结构,它是后入先出
      

  5.   


    这样多次调用同一个页面     setViewControllers会不会实例化很多个这个页面的对象呢?
      

  6.   


    这样多次调用同一个页面     setViewControllers会不会实例化很多个这个页面的对象呢?
    如果viewControllers里面本身就有你要的vc,你就把viewControllers复制一份,删掉其他不要的vc就可以了
      

  7.   

    用这个方法:    [self.navigationController popToViewController:vc animated:YES];下面英文是这个方法的注释。
    大概意思:弹出ViewController 直到指定的VC在栈顶。参数是你要跳的那个VC。要用这个方法,就需要你在跳的时候,持有要调到的VC的实例。当然,你要一下子调到第一个更简单:    [self.navigationController popToRootViewControllerAnimated:YES];
    这个方法就搞定,不需要其他任何参数。-----------------
    - (NSArray *)popToViewController:(UIViewController *)viewController animated:(BOOL)animated
    Description
    Pops view controllers until the specified view controller is at the top of the navigation stack.
    For information on how the navigation bar is updated, see Updating the Navigation Bar.Parameters
    viewController
    The view controller that you want to be at the top of the stack. This view controller must currently be on the navigation stack.
    animated
    Set this value to YES to animate the transition. Pass NO if you are setting up a navigation controller before its view is displayed.
    Returns
    An array containing the view controllers that were popped from the stack.
    Availability iOS (2.0 and later)
    Declared In UINavigationController.h
    Reference UINavigationController Class Reference