How to segue back to a UIViewController that's already loaded?

后端 未结 4 1437
我寻月下人不归
我寻月下人不归 2020-12-12 13:33

I have a view on a storyboard the has a button to perform a certain action. To perform this action though, the user must be logged in. The button handler tests if the user i

4条回答
  •  忘掉有多难
    2020-12-12 14:08

    Assuming by your use of "push" you mean that you are using a UINavigationController, then you can use the following to return to the top of the stack.

    [self.navigationController popToRootViewControllerAnimated:YES];
    

    or

    UIViewController *prevVC = [self.navigationController.viewControllers objectAtIndex:];
    [self.navigationController popToViewController:prevVC animated:YES];
    

    to pop to a specific level where is the level.

    or

    [self.navigationController popViewControllerAnimated:YES];
    

    If you just want to pop one level back up the navigation stack.

提交回复
热议问题