Search code examples
iospushviewcontroller

PushViewController iOS


I have three view controllers. MainViewController, secondViewController, thirdViewController. I would like to know once I click on done button on the thirdViewcontroller,

How could I go directly yo MainViewController instead of going back secondViewController and then MainViewcontroller by using pushViewController?


Solution

  • Assuming that your using a navigation controller, you can pop to root by calling:

    [[self navigationController] popToRootViewControllerAnimated:YES];
    

    This will bring you back to your MainViewController.