How to pop from one view controller to another view controller

前端 未结 8 1438
北荒
北荒 2021-01-31 09:53

Using iOS I Have 15 ViewControllers now I want to pop from one ViewController to another View Controller.

I am using this code:

SecondViewController *Sec         


        
8条回答
  •  渐次进展
    2021-01-31 10:30

    You can't pop to a new view controller (like you do with your secondViewController example).

    When using a UINavigationController you

    Add Controller to the stack with:

    [self.navigationController pushViewController: animated:YES];
    

    Pop to the previous one with :

    [self.navigationController popViewControllerAnimated:YES];
    

    Pop to a previous controller in the stack (Must have been pushed before) :

    [self.navigationController popToViewController: animated:YES];
    

    Go back to the root Controller with

    [self.navigationController popToRootViewControllerAnimated:YES];
    

提交回复
热议问题